-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathcall_burst.cpp
64 lines (51 loc) · 1.39 KB
/
call_burst.cpp
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
#ifdef RECKLESS_ENABLE_TRACE_LOG
#include <performance_log/trace_log.hpp>
#include <fstream>
#endif
#include <performance_log/performance_log.hpp>
#include <iostream>
#include LOG_INCLUDE
#if defined(__unix__)
#include <unistd.h>
void remove_file(char const* path)
{
unlink(path);
}
#elif defined(_WIN32)
#include <Windows.h>
void remove_file(char const* path)
{
DeleteFile(path);
}
#endif
char c = 'A';
float pi = 3.1415f;
int main()
{
remove_file("log.txt");
performance_log::logger<100000, performance_log::rdtscp_cpuid_clock> performance_log;
{
LOG_INIT(128);
// It's important to set our CPU affinity *after* the log is
// initialized, otherwise all threads will run on the same CPU.
performance_log::rdtscp_cpuid_clock::bind_cpu(0);
for(int i=0; i!=100000; ++i) {
LOG(c, i, pi);
}
for(int i=0; i!=100000; ++i) {
auto start = performance_log.start();
LOG(c, i, pi);
performance_log.stop(start);
}
performance_log::rdtscp_cpuid_clock::unbind_cpu();
LOG_CLEANUP();
}
for(auto sample : performance_log) {
std::cout << sample.start << ' ' << sample.stop << std::endl;
}
#ifdef RECKLESS_ENABLE_TRACE_LOG
std::ofstream trace_log("trace_log.txt", std::ios::trunc);
reckless::detail::g_trace_log.save(trace_log);
#endif
return 0;
}