From: Vincent van Ravesteijn Date: Sun, 24 Mar 2013 12:35:44 +0000 (+0100) Subject: Add a WIN32 equivalent for gettimeofday X-Git-Tag: 2.1.0beta1~490 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=367126bf245fb2399083a17fb1f8cffa8ed66f91;p=lyx.git Add a WIN32 equivalent for gettimeofday This function does not really returns the "time of day", but it will suffice to evaluate elapsed times. --- diff --git a/src/support/pmprof.h b/src/support/pmprof.h index 7cd2efcbfb..7f74fe2646 100644 --- a/src/support/pmprof.h +++ b/src/support/pmprof.h @@ -11,7 +11,11 @@ #ifndef PMPROF_H #define PMPROF_H +#ifdef _WIN32 +#include +#else #include +#endif #include /** How to use this trivial profiler: @@ -92,11 +96,29 @@ */ +#ifdef _WIN32 + +/* This function does not really returns the "time of day", + * but it will suffice to evaluate elapsed times. + */ +int gettimeofday(struct timeval * tv, struct timezone * /*tz*/) +{ + LARGE_INTEGER frequency, t; + QueryPerformanceFrequency(&frequency); + QueryPerformanceCounter(&t); + + tv->tv_sec = long(t.QuadPart / frequency.QuadPart); + tv->tv_usec = long((1000000.0 * (t.QuadPart % frequency.QuadPart)) / frequency.QuadPart); + return 0; +} + +#endif // _WIN32 /* Helper class for gathering data. Instantiate this as a static * variable, so that its destructor will be executed when the program * ends. */ + class PMProfStat { public: PMProfStat(char const * name)