-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtrace_perf.h
More file actions
45 lines (39 loc) · 1.09 KB
/
trace_perf.h
File metadata and controls
45 lines (39 loc) · 1.09 KB
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
#ifndef TRACE_PERF_H
#define TRACE_PERF_H
#include <string>
#include "timer.h"
/**
* @brief The trace_perf class should log the execution time of a scope and
* warn if it was below a threshold.
*
* The scope is identified by a text string, example:
* {
* TRACE_PERF("running thingy");
* run_thingy();
* }
*
* The threshold is defined for each scope in a database file in the folder
* trace_perf/...
*
* Multiple database files can be used to overload the thresholds.
*
* The results stored in a complementary database file regardless of failure
* or success when the process quits.
*/
class trace_perf
{
public:
trace_perf(const char* filename, const std::string& info);
trace_perf(const trace_perf&) = delete;
trace_perf& operator=(const trace_perf&) = delete;
~trace_perf();
void reset();
void reset(const std::string& info);
static void add_database_path(const std::string& path);
private:
Timer timer;
std::string info;
std::string filename;
};
#define TRACE_PERF(info) trace_perf trace_perf_{__FILE__, info}
#endif // TRACE_PERF_H