]> Creatis software - gdcm.git/blobdiff - Testing/TestInline.cxx
* Fix compilation warnings on linux
[gdcm.git] / Testing / TestInline.cxx
index e28c473ac29b1343c8e1007e68333969f8cc47a4..1709a2c89b0ef01cf372bf7f6885a87d506da5c5 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestInline.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:01:39 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/11/18 11:46:37 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 // Which CXX_FLAGS, LINKER_FLAGS, ...,  must we set to see the difference?
 
 #include "gdcmUtil.h"
-#include "gdcmDebug.h"
-#include <iostream>
 
-#include <time.h>
-#ifdef CMAKE_HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#else
-#include <sys/timeb.h>
-#endif
+#include <iostream>
 
 void        frswap (double &a, double &b);
 void        fpswap (double *a, double *b);
@@ -149,9 +142,9 @@ int TestInline(int argc, char *argv[])
    if (argc > 1)
       nbLoop = atoi(argv[1]);
    else
-      nbLoop = 100000000;      
+      nbLoop = 10000000;      
 
-   clock_t r1, r2;
+   //clock_t r1, r2;
    struct tms tms1, tms2;
    
    double a = 1, b = 2;
@@ -161,25 +154,29 @@ int TestInline(int argc, char *argv[])
  // ----------------------------------------
  
    std::cout << "Use a macro "<< std::endl;
-   r1 = times(&tms1);   
+   //r1 = times(&tms1);
+   times(&tms1);   
    for(i = 0 ; i< nbLoop ; i++)
    {
       mswap (a,b);  
    }
-   r2 = times(&tms2);
-   std::cout 
+   //r2 = times(&tms2);
+   times(&tms2);   
+    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;
    
  // ----------------------------------------
  
    std::cout << "Use reference function" << std::endl;
-   r1 = times(&tms1);         
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       frswap (a,b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -187,12 +184,14 @@ int TestInline(int argc, char *argv[])
  // ----------------------------------------
   
    std::cout << "Use pointer function" << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       fpswap (&a, &b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;  
@@ -200,12 +199,14 @@ int TestInline(int argc, char *argv[])
  // ----------------------------------------
  
    std::cout << "Use inline, main-defined reference function" << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       ifrswap (a, b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;    
@@ -213,12 +214,14 @@ int TestInline(int argc, char *argv[])
  // ----------------------------------------
  
    std::cout << "Use inline, main-defined pointer function" << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       ifpswap (&a, &b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;
@@ -230,12 +233,15 @@ int TestInline(int argc, char *argv[])
     
    std::cout << "Use inline, .h defined, WITH inline keyword pointer function"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
-      gdcm::Util::hifpswap (&a, &b);  
+      //gdcm::Util::hifpswap (&a, &b);
+      hifpswap (&a, &b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;  
@@ -245,12 +251,15 @@ int TestInline(int argc, char *argv[])
 
    std::cout << "Use inline, .h defined, NO inline keyword pointer function"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
-      gdcm::Util::hNoifpswap (&a, &b);  
+      //gdcm::Util::hNoifpswap (&a, &b);
+      hNoifpswap (&a, &b);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -260,12 +269,14 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass uint_16 param directly"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passDirect (x, y);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -274,12 +285,14 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass uint_16 param as ref"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passRef (x, y);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -288,12 +301,14 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass uint_16 param as ptr"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passPtr (&x, &y);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -305,12 +320,14 @@ int TestInline(int argc, char *argv[])
    uint32_t m =1, n=2; 
    std::cout << "Pass uint_32 param directly"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passDirect32 (m, n);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -319,12 +336,14 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass uint32_t param as ref"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passRef32 (m, n);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -333,12 +352,14 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass uint_32 param as ptr"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passPtr32 (&m, &n);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -350,12 +371,15 @@ int TestInline(int argc, char *argv[])
    
    std::cout << "Pass double param directly"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passDirectDouble (dx, dy);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
+
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -364,12 +388,15 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass double param as ref"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passRefDouble (dx, dy);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
+
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl; 
@@ -378,12 +405,15 @@ int TestInline(int argc, char *argv[])
  
    std::cout << "Pass double param as ptr"
              << std::endl;
-   r1 = times(&tms1);     
-   for(i = 0 ; i< nbLoop ; i++)
+   //r1 = times(&tms1);
+   times(&tms1);   
+    for(i = 0 ; i< nbLoop ; i++)
    {
       passPtrDouble (&dx, &dy);  
    }
-   r2 = times(&tms2);
+   //r2 = times(&tms2);
+   times(&tms2);   
+
    std::cout 
         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
         << std::endl;