-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.h
66 lines (62 loc) · 1.48 KB
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @file timer.h
* @brief C++ Interface: timer
*
* @details Measure time between events.
*
* Copyright: See COPYING file that comes with this distribution
*
*/
#ifndef TIMER_H
#define TIMER_H
#include <iostream>
#include <sys/time.h>
#include <QFile>
#include <QString>
#include <QDateTime>
#include <QTextStream>
class Timer
{
public:
~Timer();
/**
* @brief Begin saveing the measureing results to file.
*/
void beginSaveToFile();
/**
* @brief End saveing the measureing results to file.
*/
void endSaveToFile();
/**
* @brief Begin or end outputing measureing results to console.
* @param output - Output the measureing results to console
*/
void setOutputToConsole(bool);
/**
* @brief Mark the begin of the first event.
*/
void markBegin();
/**
* @brief Mark the end of the second event.
*/
void markEnd();
/**
* @brief Returns static Timer class instance. It cannot be accessed directly because Timer is a singleton class.
*/
static Timer & getTimer();
private:
Timer();
bool save_to_file;
bool output_to_console;
timespec begin, end, temp;
QFile* file;
QTextStream* out;
/**
* @brief Get the difference of two counter readings.
* @param begin - First counter reading
* @param end - Second counter reading
* @return temp - The difference of begin and end
*/
timespec difference(timespec, timespec);
};
#endif // TIMER_H