CARLsim  3.1.3
CARLsim: a GPU-accelerated SNN simulator
stopwatch.h
Go to the documentation of this file.
1 #ifndef STOPWATCH_H
2 #define STOPWATCH_H
3 
4 #if defined(WIN32) || defined(WIN64)
5  #include <Windows.h>
6 #else
7  #include <sys/time.h>
8  #include <ctime>
9 #endif
10 
11 #include <stdint.h>
12 #include <vector> // std::vector
13 #include <string> // std::string
14 
67 class Stopwatch {
68 public:
79  Stopwatch(bool startTimer=true);
80 
86  ~Stopwatch();
87 
102  void start(const std::string& tag = "");
103 
124  uint64_t stop(bool printMessage=true, FILE* printFile=NULL);
125 
146  uint64_t lap(const std::string& tag = "");
147 
159  void reset();
160 
174  uint64_t getLapTime(const std::string& tag) const;
175 
191  uint64_t getLapTime(int index) const;
192 
220  void print(FILE* fileStream=NULL) const;
221 
222 private:
223  // This class provides a pImpl for the CARLsim User API.
224  // \see https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl/
225  class Impl;
226  Impl* _impl;
227 };
228 
229 #endif // STOPWATCH_H
void print(FILE *fileStream=NULL) const
Prints a summary to file or console.
Utility to measure script execution time (wall-clock time) in milliseconds.
Definition: stopwatch.h:67
~Stopwatch()
Stopwatch destructor.
uint64_t getLapTime(const std::string &tag) const
Looks up the execution time of a lap by its tag.
uint64_t lap(const std::string &tag="")
Ends the current lap and starts a new lap.
uint64_t stop(bool printMessage=true, FILE *printFile=NULL)
Stops the timer.
void reset()
Resets the timer.
void start(const std::string &tag="")
Starts/restarts the timer.
Stopwatch(bool startTimer=true)
Utility to measure script execution time (wall-clock time) in milliseconds.