-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick_start.cc
38 lines (29 loc) · 861 Bytes
/
quick_start.cc
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
#include "latency_collector.h"
#include "latency_dump.h"
#include <cstdlib>
#include <iostream>
#include <thread>
static LatencyCollector lat_clt;
void function3() {
collectFuncLatency(&lat_clt);
std::this_thread::sleep_for( std::chrono::milliseconds( rand() % 10 ) );
}
void function2() {
collectFuncLatency(&lat_clt);
for (size_t ii=0; ii<10; ++ii) function3();
}
void function1() {
collectFuncLatency(&lat_clt);
for (size_t ii=0; ii<3; ++ii) function2();
}
int main(int argc, char** argv) {
{
collectBlockLatency(&lat_clt, "main block");
for (size_t ii=0; ii<5; ++ii) function1();
for (size_t ii=0; ii<2; ++ii) function2();
for (size_t ii=0; ii<3; ++ii) function3();
}
LatencyDumpDefaultImpl default_dump;
std::cout << lat_clt.dump(&default_dump) << std::endl;
return 0;
}