-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
52 lines (45 loc) · 1.22 KB
/
Copy pathexample.cpp
File metadata and controls
52 lines (45 loc) · 1.22 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
46
47
48
49
50
51
52
#define PROFILER_ENABLED
#include "profiler.hpp"
#include <iostream>
#include <thread>
using namespace std::chrono_literals;
void printProfilerReport();
int main(int, char **)
{
{
ProfileBlock("Block_1");
std::this_thread::sleep_for(20ms);
{
ProfileBlock("Block_1.1");
std::this_thread::sleep_for(20ms);
std::this_thread::sleep_for(10ms);
{
ProfileBlock("Block_1.1.1");
std::this_thread::sleep_for(20ms);
std::this_thread::sleep_for(10ms);
}
}
{
ProfileBlock("Block_1.2");
std::this_thread::sleep_for(10ms);
}
std::this_thread::sleep_for(10ms);
}
{
ProfileBlock("Block_2");
std::this_thread::sleep_for(30ms);
}
printProfilerReport();
ClearProfiler();
return 0;
}
void printProfilerReport()
{
for (int i = 0; i < Profiler::size; ++i)
{
auto &entry = Profiler::entries[i];
std::string nameIndent(entry.indent * 2, ' ');
std::string timeIndent(12 - entry.indent * 4, ' ');
std::cout << nameIndent << entry.name << timeIndent << entry.elapsed << " ms" << std::endl;
}
}