]> Creatis software - gdcm.git/blobdiff - Testing/TestInline.cxx
Remove useless bug track displays
[gdcm.git] / Testing / TestInline.cxx
index e0811745b8ab5e496af3d0a22a86f8b611c83044..1709a2c89b0ef01cf372bf7f6885a87d506da5c5 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestInline.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 10:55:12 $
-  Version:   $Revision: 1.3 $
+  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>
-#endif
+#include <iostream>
 
 void        frswap (double &a, double &b);
 void        fpswap (double *a, double *b);
@@ -55,28 +50,6 @@ double     passDirect(double a,  double b);
 double     passRef(double &a, double &b);
 double     passPtr(double *a, double *b);
 
-/*  
-//To perform a full check, just put the two 'static' functions
-//hifpswap and  hNoifpswap in a .h
-
-   static inline void hifpswap(double *a, double *b)    
-   {
-      double tmp;
-      tmp = *a;
-      *a = *b;
-      *b = tmp;
-   }
-
-   static void hNoifpswap(double *a, double *b)    
-   {
-      double tmp;
-      tmp = *a;
-      *a = *b;
-      *b = tmp;
-   }
-    
-*/
-
 #define       \
 mswap(a, b)   \
 {             \
@@ -169,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;
@@ -181,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; 
@@ -207,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;  
@@ -220,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;    
@@ -233,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;
@@ -250,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;  
@@ -265,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; 
@@ -280,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; 
@@ -294,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; 
@@ -308,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; 
@@ -325,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; 
@@ -339,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; 
@@ -353,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; 
@@ -370,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; 
@@ -384,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; 
@@ -398,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;