16 #ifndef GEOS_PROFILER_H
17 #define GEOS_PROFILER_H
19 #include <geos/export.h>
22 #if defined(__MINGW32__)
28 extern _CRTIMP
void __cdecl _tzset (
void);
29 __MINGW_IMPORT
int _daylight;
30 __MINGW_IMPORT
long _timezone;
31 __MINGW_IMPORT
char *_tzname[2];
35 #if defined(_MSC_VER) || defined(__MINGW32__) && !defined(HAVE_GETTIMEOFDAY)
36 #include <geos/timeval.h>
53 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
65 class GEOS_DLL Profile {
68 Profile(std::string name);
75 gettimeofday(&starttime, NULL);
81 gettimeofday(&stoptime, NULL);
82 double elapsed = 1000000*(stoptime.tv_sec-starttime.tv_sec)+
83 (stoptime.tv_usec-starttime.tv_usec);
85 timings.push_back(elapsed);
87 if ( timings.size() == 1 ) max = min = elapsed;
90 if ( elapsed > max ) max = elapsed;
91 if ( elapsed < min ) min = elapsed;
93 avg = totaltime / timings.size();
97 double getMax()
const;
100 double getMin()
const;
103 double getTot()
const;
106 double getAvg()
const;
109 size_t getNumTimings()
const;
118 struct timeval starttime, stoptime;
121 std::vector<double> timings;
143 class GEOS_DLL Profiler {
155 static Profiler *instance(
void);
162 void start(std::string name);
169 void stop(std::string name);
172 Profile *
get(std::string name);
174 std::map<std::string, Profile *> profs;
179 std::ostream& operator<< (std::ostream& os,
const Profile&);
182 std::ostream& operator<< (std::ostream& os,
const Profiler&);
191 #endif // ndef GEOS_PROFILER_H