15 #ifndef GEOS_PROFILER_H
16 #define GEOS_PROFILER_H
19 #include <geos/export.h>
23 #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
29 extern _CRTIMP
void __cdecl _tzset (
void);
30 __MINGW_IMPORT
int _daylight;
31 __MINGW_IMPORT
long _timezone;
32 __MINGW_IMPORT
char *_tzname[2];
36 #if defined(_MSC_VER) || defined(__MINGW32__) && !defined(HAVE_GETTIMEOFDAY) && !defined(__MINGW64_VERSION_MAJOR)
37 #include <geos/timeval.h>
54 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
66 class GEOS_DLL Profile {
69 Profile(std::string name);
76 gettimeofday(&starttime, NULL);
82 gettimeofday(&stoptime, NULL);
83 double elapsed = 1000000*(stoptime.tv_sec-starttime.tv_sec)+
84 (stoptime.tv_usec-starttime.tv_usec);
86 timings.push_back(elapsed);
88 if ( timings.size() == 1 ) max = min = elapsed;
91 if ( elapsed > max ) max = elapsed;
92 if ( elapsed < min ) min = elapsed;
94 avg = totaltime / timings.size();
98 double getMax()
const;
101 double getMin()
const;
104 double getTot()
const;
107 double getAvg()
const;
110 size_t getNumTimings()
const;
119 struct timeval starttime, stoptime;
122 std::vector<double> timings;
144 class GEOS_DLL Profiler {
156 static Profiler *instance(
void);
163 void start(std::string name);
170 void stop(std::string name);
173 Profile *
get(std::string name);
175 std::map<std::string, Profile *> profs;
180 std::ostream& operator<< (std::ostream& os,
const Profile&);
183 std::ostream& operator<< (std::ostream& os,
const Profiler&);
192 #endif // ndef GEOS_PROFILER_H