]> Creatis software - gdcm.git/blob - Example/TestPrintTime.cxx
* Rename the NO_SEQ, NO_SHADOW, NO_SHADOWSEQ to
[gdcm.git] / Example / TestPrintTime.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestPrintTime.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/08/30 14:40:28 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 // TODO : check what's *actually* usefull
20
21 #include "gdcmFile.h"
22 #include "gdcmUtil.h"
23 #include "gdcmCommon.h"
24
25 #include <iostream>
26 #include <time.h>
27 #include <sys/times.h>
28
29 #include <iomanip> // for std::ios::left, ...
30
31 // Where is it?
32 //#define CLK_TCK 1  ///usr/include/bits/time.h:41: warning: this is the location of the previous definition
33
34
35 //Generated file:
36 #include "gdcmDataImages.h"
37 int main(int, char *[])
38 {
39    clock_t r1, r2, r3, r4;
40    struct tms tms1, tms2, tms3, tms4;
41    gdcm::File *e1;
42
43    //std::ostream os = std::cout;
44    //std::ostringstream s;
45
46    int i = 0;
47    while( gdcmDataImages[i] != 0 )
48    {
49       std::string filename = GDCM_DATA_ROOT;
50       filename += "/";  //doh!
51       filename += gdcmDataImages[i];
52
53       e1= new gdcm::File( );
54       r1 = times(&tms1);
55       e1->SetFileName( filename );
56       e1->Load( );
57       r2 = times(&tms2);
58       if (!e1->IsReadable())
59       std::cout << "-----------Not Readable " << std::endl;
60       delete e1;
61       e1= new gdcm::File( );
62       e1->SetLoadMode( GDCM_LD_NOSEQ | GDCM_LD_NOSHADOW );
63       r3 = times(&tms3);
64       e1->SetFileName( filename );
65       e1->Load( );
66       
67       r4 = times(&tms4);
68       if (!e1->IsReadable())
69          std::cout << "-----------Not Readable " << std::endl;
70       delete e1;
71  
72       std::cout 
73         << std::setw(60-strlen(gdcmDataImages[i])) << " "
74         << gdcmDataImages[i] << "   " 
75         << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
76         << " vs  "
77         << (long) ((tms4.tms_utime)  - (tms3.tms_utime));
78                 
79       std::cout << "\twith clock time : " << r2-r1 << " vs " << r4-r3 
80           << std::endl;
81
82       i++;
83    }
84
85    std::cout << "---------------------------------------------------" << std::endl;
86
87    r1 = times(&tms1);
88    for(int k=0;k<1; k++) // run many tiles to increase time ...
89    {
90       i=0;
91       while( gdcmDataImages[i] != 0 )
92       {
93          std::string filename = GDCM_DATA_ROOT;
94          filename += "/";  //doh!
95          filename += gdcmDataImages[i];
96
97          e1= new gdcm::File( );
98          e1->SetFileName( filename );
99          e1->Load( ); 
100          if (!e1->IsReadable())
101             std::cout << "-----------Not Readable " << std::endl;
102          delete e1;
103
104         i++;
105     }
106  
107  }
108    r2 = times(&tms2);
109
110 // ---------------------------
111    r3 = times(&tms3);
112    for(int k=0;k<1; k++)
113    {
114
115      i=0;
116      while( gdcmDataImages[i] != 0 )
117      {
118         std::string filename = GDCM_DATA_ROOT;
119         filename += "/";  //doh!
120         filename += gdcmDataImages[i];
121
122         e1= new gdcm::File( );
123         e1->SetLoadMode( GDCM_LD_NOSEQ | GDCM_LD_NOSHADOW );
124         e1->SetFileName( filename );
125         e1->Load( );
126         if (!e1->IsReadable())
127           std::cout << "-----------Not Readable " << std::endl;
128         delete e1;
129         i++;
130       }
131    }
132     r4 = times(&tms4);
133
134     std::cout  
135           << (long) ((tms2.tms_utime)  - (tms1.tms_utime)) 
136           << "\t\t "
137           << (long) ((tms4.tms_utime)  - (tms3.tms_utime)) 
138           << std::endl;
139           std::cout << "---------------------------------------------------" << std::endl;
140
141    return 0;
142 }