stattimer.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2014 Shingo W. Kagami. All rights reserved.
3 
4  http://code.google.com/p/stattimer/
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14 
15 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 SUCH DAMAGE.
26 */
27 
28 /**
29  @file stattimer.hpp
30  @brief A stopwatch timer library that reports statistics
31  @author Shingo W. Kagami
32 */
33 
34 #ifndef _STATTIMER_H_
35 #define _STATTIMER_H_
36 
37 #include <math.h>
38 #include <string.h>
39 #include <vector>
40 #include <map>
41 #include <string>
42 #include <iostream>
43 #include <sstream>
44 #include <fstream>
45 #include <iomanip>
46 
47 /**
48  * Struct that a STimerReporterFunc function receives as an argument.
49  */
50 struct STimerRecords {
51  int id; ///< Id number of the timer
52  std::string label; ///< Label of the timer
53  double mean; ///< mean of elapsed time [s]
54  double stddev; ///< standard deviation of elapsed time [s]
55  double maximum; ///< maximum of elapsed time [s]
56  double minimum; ///< minimum of elapsed time [s]
57  std::vector<double> timebuf; ///< vector containing the recent values of elapsed time
58  int nsample; ///< number of samples used to compute the above statistics
59 };
60 
61 /**
62  * Type of a user-defined reporter function.
63  *
64  * @param rec [in] Timer statistics record
65  */
66 typedef std::string (*STimerReporterFunc)(STimerRecords& rec);
67 
68 // forward declarations
69 class STimer;
70 template<typename T> class STimerList_;
71 template<typename T> class STimerScoped_;
72 
73 /**
74  * See template class STimerList_.
75  */
77 
78 /**
79  * See template class STimerScoped_.
80  */
82 
83 /**
84  * Class for a single timer. This is used by STimerList class and will
85  * not be used by a user directly.
86  */
87 class STimer {
88  friend class STimerList_<STimer>;
89 public:
90  STimer() : start_count(0.0), nsample(0),
91  dsum(0.0), dsqrsum(0.0), dmax(0.0), dmin(0.0),
92  idx_timebuf(-1), is_recording(false) {}
93  ~STimer() {}
94 protected:
95  void start() {
96  start_count = tickCount();
97  is_recording = true;
98  }
99  void start(double start_count_value) {
100  start_count = start_count_value;
101  is_recording = true;
102  }
103  double stop() {
104  double stop_count = tickCount();
105  double delta = (stop_count - start_count) * tickPeriod();
106  registerTime(delta);
107  return stop_count; // used in laptime()
108  }
109  void registerTime(double delta) {
110  if (is_recording) {
111  dsum += delta;
112  dsqrsum += delta * delta;
113  if (nsample == 0) {
114  dmax = dmin = delta;
115  } else {
116  if (delta > dmax) {
117  dmax = delta;
118  }
119  if (delta < dmin) {
120  dmin = delta;
121  }
122  }
123  if (idx_timebuf >= 0) {
124  timebuf.at(idx_timebuf) = delta;
125  idx_timebuf++;
126  if (idx_timebuf >= (int)timebuf.size()) {
127  idx_timebuf = 0;
128  }
129  }
130  nsample++;
131  is_recording = false;
132  }
133  }
134  std::string report(STimerReporterFunc fn = NULL) const {
135  if (fn == NULL) {
136  fn = reporter_func;
137  }
138  if (nsample == 0 || fn == NULL) {
139  std::string empty_str;
140  return empty_str;
141  }
142  STimerRecords rec;
143  calcStat(rec);
144  return fn(rec);
145  }
146  void calcStat(STimerRecords& rec) const {
147  rec.id = id;
148  rec.label = label;
149  rec.mean = dsum / nsample;
150  double var = dsqrsum / nsample - rec.mean * rec.mean;
151  rec.stddev = var < 0 ? 0.0 : sqrt(var);
152  rec.maximum = dmax;
153  rec.minimum = dmin;
154  rec.nsample = nsample;
155  if (idx_timebuf >= 0) {
156  int bufsize = (int)timebuf.size();
157  if (timebuf.at(idx_timebuf) < 0) {
158  rec.timebuf.assign(idx_timebuf, 0);
159  for (int i = 0; i < idx_timebuf; i++) {
160  rec.timebuf.at(i) = timebuf.at(i);
161  }
162  } else {
163  rec.timebuf.assign(bufsize, 0);
164  for (int i = idx_timebuf; i < bufsize; i++) {
165  rec.timebuf.at(i - idx_timebuf) = timebuf.at(i);
166  }
167  for (int i = 0; i < idx_timebuf; i++) {
168  rec.timebuf.at(bufsize - idx_timebuf + i) = timebuf.at(i);
169  }
170  }
171  }
172  }
173  void setLabel(std::string l) {
174  label = l;
175  }
177  reporter_func = f;
178  }
179  void initTimeBuf(int len) {
180  timebuf.assign(len, -1.0);
181  idx_timebuf = 0;
182  }
183  void setId(int i) {
184  id = i;
185  }
186  inline static double tickCount();
187  inline static double tickPeriod();
188 
189  int id;
190  double start_count;
191  int nsample;
192  double dsum;
193  double dsqrsum;
194  double dmax;
195  double dmin;
196  std::vector<double> timebuf;
199  std::string label;
201 };
202 
203 /**
204  * Class that contains and manages multiple timers.
205  *
206  * This is designed as a template class just for testability (i.e. to
207  * cope with a mock subclass of STimer). Users should always use
208  * STimerList, which is typedef of STimerList_<STimer>.
209  */
210 template<typename TimerType>
211 class STimerList_ {
212 public:
213  /**
214  * Constructor that generates n timers.
215  * @param n [in] number of timers initially generated
216  * @param rfunc [in] reporter function, which defaults to reporterDefault
217  * @param outfile [in] output file name, which defaults to stdout
218  */
219  STimerList_(int n, const STimerReporterFunc rfunc = reporterDefault,
220  const std::string& outfile = "")
221  : ntimer(n), timer(ntimer), outfile(outfile) {
222  init(rfunc);
223  }
224  /** Constructor that generates ntimer_default (= 20) timers.
225  * @param rfunc [in] reporter function, which defaults to reporterDefault
226  * @param outfile [in] output file name, which defaults to stdout
227  */
228  STimerList_(STimerReporterFunc const rfunc = reporterDefault,
229  const std::string& outfile = "")
230  : ntimer(ntimer_default), timer(ntimer), outfile(outfile) {
231  init(rfunc);
232  }
233  /** Destructor that calls report() and put the result to stdout. */
235  if (outfile == "") {
236  std::cout << report();
237  } else {
238  std::ofstream ofs(outfile);
239  ofs << report();
240  }
241  }
242 
243  /**
244  * Start the timer whose id = i. If the timer does not exist, it
245  * is automatially generated.
246  *
247  * @param i [in] Timer id
248  */
249  inline void start(int i) {
250  if (i >= ntimer) { expand(i + 1); }
251  timer.at(i).start();
252  }
253  /**
254  * Start the timer with the specified label. If the timer does
255  * not exist, it is automatially generated.
256  *
257  * @param label [in] Timer label
258  * @return Timer id associated to the label
259  */
260  inline int start(const char *label) {
261  int i = findLabel(label);
262  timer.at(i).start();
263  return i;
264  }
265 
266  /**
267  * Stop the timer whose id = i and update the statistics record.
268  * If the timer has not been started, nothing is done. If the
269  * timer does not exist, it is automatially generated (and of
270  * course nothing is recorded).
271  *
272  * @param i [in] Timer id
273  */
274  inline void stop(int i) {
275  if (i >= ntimer) { expand(i + 1); }
276  timer.at(i).stop();
277  }
278 
279  /**
280  * Stop the timer with the specified label. See description of
281  * stop(int).
282  *
283  * @param label [in] Timer label
284  * @return Timer id associated to the label
285  */
286  inline int stop(const char *label) {
287  int i = findLabel(label);
288  timer.at(i).stop();
289  return i;
290  }
291 
292  /**
293  * Record the lap time of the timer whose id = i. If the timer
294  * does not exist, it is automatially generated. It is equivalent
295  * to calling stop(i) followed by start(i) with zero delay.
296  *
297  * @param i [in] Timer id
298  */
299  inline void laptime(int i) {
300  if (i >= ntimer) { expand(i + 1); }
301  double t = timer.at(i).stop();
302  timer.at(i).start(t);
303  }
304  /**
305  * Record the lap time of the timer with the specified label. See
306  * description of laptime(int).
307  *
308  * @param label [in] Timer label
309  * @return Timer id associated to the label
310  */
311  inline int laptime(const char *label) {
312  int i = findLabel(label);
313  double t = timer.at(i).stop();
314  timer.at(i).start(t);
315  return i;
316  }
317  /**
318  * Initialize the buffer to record recent values of elapsed time
319  * of the timer whose id = i. If the timer does not exist, it is
320  * automatially generated.
321  *
322  * After this is called, the timer starts recording the elapsed
323  * time between each start() and stop() (or consecutive laptime())
324  * in addition to updating the statistics data. Only the recent
325  * len values at most are preserved. The recorded values can be
326  * accessed in the STimerReporterFunc function as rec.timebuf
327  * vector.
328  *
329  * @param i [in] Timer id
330  * @param len [in] Length of the buffer
331  */
332  void initTimeBuf(int i, int len) {
333  if (i >= ntimer) { expand(i + 1); }
334  timer.at(i).initTimeBuf(len);
335  }
336  /**
337  * Initialize the buffer to record recent values of elapsed time
338  * of the timer with the specified label. See description of
339  * initTimeBuf(i, len).
340  *
341  * @param label [in] Timer label
342  * @param len [in] Length of the buffer
343  * @return Timer id associated to the label
344  */
345  int initTimeBuf(const char *label, int len) {
346  int i = findLabel(label);
347  timer.at(i).initTimeBuf(len);
348  return i;
349  }
350  /**
351  * Set the label to the timer whose id = i. If the same label
352  * already exists (for another timer), that old label is cleared
353  * in advance. If the timer i does not exist, it is
354  * automatically generated. If the timer i already has a label,
355  * the old label is cleared in advance.
356  *
357  * @param i [in] Timer id to which the label is set.
358  * @param label [in] Timer label
359  */
360  void setLabel(int i, const char *label) {
361  std::string label_str(label);
362  if (labelExists(label_str)) {
363  int old_i = label_assoc[label_str];
364  clearLabel(old_i);
365  }
366  if (i >= ntimer) {
367  expand(i + 1);
368  } else if (hasLabel(i)) {
369  clearLabel(i);
370  }
371  doSetLabel(i, label_str);
372  }
373 
374  /**
375  * Set the reporter function to the timer i. If the timer does not
376  * exist, it is automatially generated. The reporter functions of
377  * the other timers are unchanged.
378  *
379  * @param i [in] Timer id to which the reporter function is associated
380  * @param fn [in] Reporter function. When fn = NULL, nothing is reported.
381  */
383  if (i >= ntimer) { expand(i + 1); }
384  timer.at(i).setReporterFunc(fn);
385  }
386  /**
387  * Set the reporter function to the timer specified with the label. If the timer does not
388  * exist, it is automatially generated. The reporter functions of
389  * the other timers are unchanged.
390  *
391  * @param label [in] Label of the timer to which the reporter function is associated
392  * @param fn [in] Reporter function. When fn = NULL, nothing is reported.
393  * @return Timer id associated to the label
394  */
395  int setReporterFunc(const char *label, STimerReporterFunc fn) {
396  int i = findLabel(label);
397  timer.at(i).setReporterFunc(fn);
398  return i;
399  }
400  /**
401  * Set the reporter function to all the timers. This reporter
402  * function is also applied to the timers that will be generated
403  * in future.
404  *
405  * @param fn [in] Reporter function. When fn = NULL, nothing is reported.
406  */
408  common_reporter_func = fn;
409  for (int i = 0; i < ntimer; i++) {
410  timer.at(i).setReporterFunc(fn);
411  }
412  }
413  /**
414  * Generate the report of the timer i and return it as string.
415  * Reporter function to be used can optionally be specified. If
416  * the timer i does not exist, it is automatically generated (and
417  * an empty string is reported).
418  *
419  * @param i [in] Timer id
420  * @param fn [in] Reporter function. If not specified, the
421  * function set by setReporterFunc is used.
422  * @return Generated report
423  */
424  std::string report(int i, STimerReporterFunc fn = NULL) {
425  if (i >= ntimer) { expand(i + 1); }
426  return timer.at(i).report(fn);
427  }
428  /**
429  * Generate the report of the timer with the specified label and
430  * return it as string. See description of report(i, fn).
431  *
432  * @param label [in] Timer label
433  * @param fn [in] Reporter function. If not specified, the
434  * function set by setReporterFunc is used.
435  * @return Generated report
436  */
437  std::string report(const char *label, STimerReporterFunc fn = NULL) {
438  int i = findLabel(label);
439  return timer.at(i).report(fn);
440  }
441  /**
442  * Generate the reports of all the timer and return the
443  * concatenated string of the reports. Reporter function to be
444  * used can optionally be specified.
445  *
446  * @param fn [in] Reporter function. If not specified, the
447  * function set by setReporterFunc is used for each timer.
448  * @return Generated report
449  */
450  std::string report(STimerReporterFunc fn = NULL) const {
451  std::ostringstream stream;
452  for (int i = 0; i < (int)timer.size(); i++) {
453  stream << timer.at(i).report(fn);
454  }
455  return stream.str();
456  }
457 
458  /**
459  * Generate and return STimerRecords object of the timer whose id
460  * = i. If the timer i does not exist, it is automatically
461  * generated (and an empty records are returned). This may be
462  * useful when a user wants the statistics in a form other than
463  * string.
464  *
465  * @param i [in] Timer id
466  * @return Generated record object
467  */
469  if (i >= ntimer) { expand(i + 1); }
470  STimerRecords rec;
471  timer.at(i).calcStat(rec);
472  return rec;
473  }
474  /**
475  * Generate and return STimerRecords object of the timer
476  * with the specified label. See description of calcStat(i).
477  *
478  * @param label [in] Timer label
479  * @return Generated record object
480  */
481  STimerRecords calcStat(const char *label) {
482  int i = findLabel(label);
483  STimerRecords rec;
484  timer.at(i).calcStat(rec);
485  return rec;
486  }
487 
488  static std::string reporterDefault(STimerRecords& rec) {
489  std::ostringstream stream;
490  if (!rec.label.empty()) {
491  stream << rec.label << ":" << std::endl;
492  } else {
493  stream << rec.id << ":" << std::endl;
494  }
495  stream << std::fixed << std::setprecision(3)
496  << " mean = " << 1000.0 * rec.mean
497  << " [ms], std = " << 1000.0 * rec.stddev
498  << ", max/min = " << 1000.0 * rec.maximum
499  << "/" << 1000.0 * rec.minimum
500  << "; " << rec.nsample
501  << " iter." << std::endl;
502  return stream.str();
503  }
504 
505  static std::string reporterTSV(STimerRecords& rec) {
506  std::ostringstream stream;
507  stream << rec.id << "\t"
508  << "\"" << rec.label << "\"\t"
509  << std::fixed << std::setprecision(3)
510  << 1000.0 * rec.mean << "\t"
511  << 1000.0 * rec.stddev << "\t"
512  << 1000.0 * rec.maximum << "\t"
513  << 1000.0 * rec.minimum << "\t"
514  << rec.nsample << std::endl;
515  return stream.str();
516  }
517 
518 private:
519  void init(const STimerReporterFunc rfunc) {
520  common_reporter_func = rfunc;
521  for (int i = 0; i < ntimer; i++) {
522  timer.at(i).setId(i);
523  timer.at(i).setReporterFunc(rfunc);
524  }
525  }
526  inline void clearLabel(int i) {
527  label_assoc.erase(timer.at(i).label);
528  timer.at(i).setLabel("");
529  }
530  inline void doSetLabel(int i, std::string& label) {
531  timer.at(i).setLabel(label);
532  label_assoc[label] = i;
533  }
534  inline void expand(int new_ntimer) {
535  timer.resize(new_ntimer, TimerType());
536  for (int i = ntimer; i < new_ntimer; i++) {
537  timer.at(i).setId(i);
538  timer.at(i).setReporterFunc(common_reporter_func);
539  }
540  ntimer = new_ntimer;
541  }
542  inline int findLabel(const char *label) {
543  std::string label_str(label);
544  std::map<std::string, int>::iterator it = label_assoc.find(label_str);
545  if (it == label_assoc.end()) {
546  expand(ntimer + 1);
547  doSetLabel(ntimer - 1, label_str);
548  }
549  return label_assoc[label_str];
550  }
551  bool labelExists(const std::string& label) const {
552  return label_assoc.find(label) != label_assoc.end();
553  }
554  bool hasLabel(int i) const {
555  return label_assoc.find(timer.at(i).label) != label_assoc.end();
556  }
557 
558  static const int ntimer_default = 20;
559  int ntimer;
560  std::vector<TimerType> timer;
561  std::map<std::string, int> label_assoc;
562  STimerReporterFunc common_reporter_func;
563  std::string outfile;
564 };
565 
566 /**
567  * Class for a scoped timer object. It makes a specified timer to
568  * measure the elapsed time between the time when it is constructed
569  * and the time when it is destructed.
570  *
571  * This is designed as a template class just for testability (i.e. to
572  * cope with a mock subclass of STimer). Users should always use
573  * STimerScoped, which is typedef of STimerScoped_<STimer>.
574  *
575  */
576 template <typename TimerType>
577 class STimerScoped_ {
578 public:
579  /**
580  * Constructor that starts the timer i in the STimerList stlist.
581  *
582  * @param stlist [in] STimerList that contains the timer to be used
583  * @param i [in] Timer id
584  */
585  STimerScoped_(STimerList_<TimerType>& stlist, int i) : st(stlist), idx(i) {
586  st.start(idx);
587  }
588  /**
589  * Constructor that starts the timer with specified label in the
590  * STimerList stlist.
591  *
592  * @param stlist [in] STimerList that contains the timer to be used
593  * @param label [in] Timer label
594  */
596  : st(stlist) {
597  idx = st.start(label);
598  }
599  /**
600  * Destructor in which the timer is stopped.
601  */
603  st.stop(idx);
604  }
605 private:
607  int idx;
608 };
609 
610 
611 
612 /* Derived from OpenCV (core/src/system.cpp) */
613 #if defined WIN32 || defined _WIN32 || defined WINCE
614 #include <windows.h>
615 double STimer::tickCount() {
616  LARGE_INTEGER counter;
617  QueryPerformanceCounter(&counter);
618  return (double)counter.QuadPart;
619 }
620 double STimer::tickPeriod() {
621  static double tick_period = 0.0;
622  if (tick_period == 0.0) {
623  LARGE_INTEGER freq;
624  QueryPerformanceFrequency(&freq);
625  tick_period = 1.0 / (double)freq.QuadPart;
626  }
627  return tick_period;
628 }
629 
630 #elif (defined __linux || defined __linux__) && defined CLOCK_MONOTONIC_RAW
631 #include <time.h>
632 double STimer::tickCount() {
633  struct timespec tp;
634  clock_gettime(CLOCK_MONOTONIC, &tp);
635  return (double)((long long int)tp.tv_sec * 1000000000 + tp.tv_nsec);
636 }
637 double STimer::tickPeriod() {
638  return 1e-9;
639 }
640 
641 #elif defined __MACH__ && defined __APPLE__
642 #include <mach/mach_time.h>
643 double STimer::tickCount() {
644  return (double)mach_absolute_time();
645 }
646 double STimer::tickPeriod() {
647  static double tick_period = 0.0;
648  if (tick_period == 0.0) {
649  mach_timebase_info_data_t sTimebaseInfo;
650  mach_timebase_info(&sTimebaseInfo);
651  tick_period = sTimebaseInfo.numer / sTimebaseInfo.denom * 1e-9;
652  }
653  return tick_period;
654 }
655 
656 #else // other Unix-like
657 #include <sys/time.h>
659  struct timeval tv;
660  struct timezone tz;
661  gettimeofday(&tv, &tz);
662  return (double)(tv.tv_sec * 1000000 + tv.tv_usec);
663 }
665  return 1e-6;
666 }
667 #endif
668 
669 #endif /* _STATTIMER_H_ */
std::string report(const char *label, STimerReporterFunc fn=NULL)
Definition: stattimer.hpp:437
STimerList_< STimer > STimerList
Definition: stattimer.hpp:71
int start(const char *label)
Definition: stattimer.hpp:260
double dmax
Definition: stattimer.hpp:194
STimerRecords calcStat(const char *label)
Definition: stattimer.hpp:481
int idx_timebuf
Definition: stattimer.hpp:197
int stop(const char *label)
Definition: stattimer.hpp:286
void initTimeBuf(int i, int len)
Definition: stattimer.hpp:332
double stddev
standard deviation of elapsed time [s]
Definition: stattimer.hpp:54
double stop()
Definition: stattimer.hpp:103
void stop(int i)
Definition: stattimer.hpp:274
STimerList_(STimerReporterFunc const rfunc=reporterDefault, const std::string &outfile="")
Definition: stattimer.hpp:228
std::string(* STimerReporterFunc)(STimerRecords &rec)
Definition: stattimer.hpp:66
std::string label
Label of the timer.
Definition: stattimer.hpp:52
std::string report(STimerReporterFunc fn=NULL) const
Definition: stattimer.hpp:450
STimerList_(int n, const STimerReporterFunc rfunc=reporterDefault, const std::string &outfile="")
Definition: stattimer.hpp:219
int id
Id number of the timer.
Definition: stattimer.hpp:51
int nsample
Definition: stattimer.hpp:191
std::vector< double > timebuf
vector containing the recent values of elapsed time
Definition: stattimer.hpp:57
static double tickCount()
Definition: stattimer.hpp:658
std::string label
Definition: stattimer.hpp:199
void laptime(int i)
Definition: stattimer.hpp:299
void setReporterFunc(int i, STimerReporterFunc fn)
Definition: stattimer.hpp:382
void start(double start_count_value)
Definition: stattimer.hpp:99
void setLabel(int i, const char *label)
Definition: stattimer.hpp:360
std::string report(STimerReporterFunc fn=NULL) const
Definition: stattimer.hpp:134
double maximum
maximum of elapsed time [s]
Definition: stattimer.hpp:55
void setReporterFunc(STimerReporterFunc fn)
Definition: stattimer.hpp:407
~STimer()
Definition: stattimer.hpp:93
int nsample
number of samples used to compute the above statistics
Definition: stattimer.hpp:58
void start(int i)
Definition: stattimer.hpp:249
void registerTime(double delta)
Definition: stattimer.hpp:109
STimer()
Definition: stattimer.hpp:90
STimerScoped_< STimer > STimerScoped
Definition: stattimer.hpp:81
std::string report(int i, STimerReporterFunc fn=NULL)
Definition: stattimer.hpp:424
void calcStat(STimerRecords &rec) const
Definition: stattimer.hpp:146
void setId(int i)
Definition: stattimer.hpp:183
STimerScoped_(STimerList_< TimerType > &stlist, int i)
Definition: stattimer.hpp:585
bool is_recording
Definition: stattimer.hpp:198
double dsqrsum
Definition: stattimer.hpp:193
int setReporterFunc(const char *label, STimerReporterFunc fn)
Definition: stattimer.hpp:395
static double tickPeriod()
Definition: stattimer.hpp:664
void setLabel(std::string l)
Definition: stattimer.hpp:173
static std::string reporterTSV(STimerRecords &rec)
Definition: stattimer.hpp:505
STimerScoped_(STimerList_< TimerType > &stlist, const char *label)
Definition: stattimer.hpp:595
int laptime(const char *label)
Definition: stattimer.hpp:311
void start()
Definition: stattimer.hpp:95
double mean
mean of elapsed time [s]
Definition: stattimer.hpp:53
void initTimeBuf(int len)
Definition: stattimer.hpp:179
std::vector< double > timebuf
Definition: stattimer.hpp:196
double start_count
Definition: stattimer.hpp:190
int initTimeBuf(const char *label, int len)
Definition: stattimer.hpp:345
int id
Definition: stattimer.hpp:189
double minimum
minimum of elapsed time [s]
Definition: stattimer.hpp:56
STimerReporterFunc reporter_func
Definition: stattimer.hpp:200
STimerRecords calcStat(int i)
Definition: stattimer.hpp:468
static std::string reporterDefault(STimerRecords &rec)
Definition: stattimer.hpp:488
double dsum
Definition: stattimer.hpp:192
void setReporterFunc(STimerReporterFunc f)
Definition: stattimer.hpp:176
double dmin
Definition: stattimer.hpp:195