Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
profile.h
Go to the documentation of this file.
1 #ifdef WIN32
2 #include <time.h>
3 #else
4 
5 #include <unistd.h>
6 #include <sys/time.h>
7 
8 #define RESETTIME() startTime()
9 #define REPORTTIME( comment ) endTime( comment, __FILE__, __LINE__ )
10 
11 static timeval start;
12 static inline void startTime()
13 {
14  gettimeofday( &start, NULL );
15 }
16 
17 static inline void endTime( const char *comment, const char *file, int lineno )
18 {
19  timeval end;
20  gettimeofday( &end, NULL );
21  double time = end.tv_sec-start.tv_sec+(end.tv_usec-start.tv_usec)/1000000.0;
22  std::clog<<file<<"("<<comment<<"):"<<lineno<<": "<<time<<std::endl;
23 }
24 #endif
25