27 # include <sys/time.h>
31 std::map<String, Timer::StopWatch> Timer::stopwatches;
38 double Timer::getTime()
43 return ((tim.wDay * 24.0 + tim.wHour) * 60.0 + tim.wMinute) * 60.0 +
44 tim.wSecond + (tim.wMilliseconds / 1000.0);
47 gettimeofday(&tim,
nullptr);
48 return double(tim.tv_sec) + (double(tim.tv_usec) / 1000000.0);
59 StopWatch &sw = stopwatches[timername];
75 StopWatch &sw = stopwatches[timername];
76 if (sw.stops.size() > 0)
77 pt = sw.stops.back().second;
80 sw.stops.push_back(std::make_pair(splitname, t));
92 StopWatch &sw = stopwatches[timername];
93 if (sw.stops.size() == 0)
94 return _(
"Unused stopwatch.");
98 s += timername + U
"\n";
99 s +=
_(
"Total time: ");
101 double tot = sw.stops.back().second - pt;
104 for (StopTime &st : sw.stops)
106 s += U
"\n" + st.first + U
": ";
107 double thistime = st.second - pt;
112 s += (thistime * 100.0) / tot;
127 stopwatches.erase(timername);
130 static const String CRN_TIMER_UNIQUE_NAME(U
"ceci n'est pas un nom");
138 Start(CRN_TIMER_UNIQUE_NAME);
148 double t =
Split(CRN_TIMER_UNIQUE_NAME, CRN_TIMER_UNIQUE_NAME);
149 Destroy(CRN_TIMER_UNIQUE_NAME);
A UTF32 character string class.
static int & Precision() noexcept
Precision of the floating point conversion.
static String Stats(const String &timername)
Dumps statistics to a string.
static double Split(const String &timername, const String &splitname)
Records time in a stopwatch.
static void Destroy(const String &timername)
Frees a stopwatch.
static double Stop()
Stops the quick stopwatch.
static void Start()
Starts the quick stopwatch.