RecFilter
timing.h
Go to the documentation of this file.
1 #ifndef _TIMING_H_
2 #define _TIMING_H_
3 
4 #include <iostream>
5 #include <fstream>
6 #include <string>
7 
8 /** Logging utility */
9 class Log {
10 private:
11  std::ofstream fout;
12 
13 public:
14  Log(std::string filename) {
15  if (!filename.empty()) {
16  fout.open(filename);
17  }
18  }
19 
20  template<typename T>
21  std::ostream& operator<<(T x) {
22  if (fout.is_open()) {
23  fout << x;
24  return fout;
25  } else {
26  std::cerr << x;
27  return std::cerr;
28  }
29  }
30 };
31 
32 /** Compute the throughput in Gibipixels = 2^30 pixels
33  * \param runtime running time in milliseconds
34  * \param pixels number of pixels
35  * \returns throughput in MiP/s
36  */
37 float throughput(float runtime, int pixels);
38 
39 /**
40  * Millisecond-precision timer function
41  * \return Clock value in milliseconds
42  *
43  * This routine implements a timer with millisecond precision. In order to
44  * obtain timing at high resolution, platform-specific functions are needed:
45  *
46  * - On Windows systems, the GetSystemTime function is used.
47  * - On Mac and POSIX systems, the gettimeofday function is used.
48  *
49  * Preprocessor symbols are checked in attempt to detect whether the platform
50  * is POSIX or Windows or Mac and defines millisecond_timer() accordingly.
51  */
52 unsigned long millisecond_timer(void);
53 
54 #endif // _TIMING_H_
Log(std::string filename)
Definition: timing.h:14
unsigned long millisecond_timer(void)
Millisecond-precision timer function.
std::ostream & operator<<(T x)
Definition: timing.h:21
float throughput(float runtime, int pixels)
Compute the throughput in Gibipixels = 2^30 pixels.
Logging utility.
Definition: timing.h:9