-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest.cpp
81 lines (65 loc) · 1.21 KB
/
Test.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "MMeter.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <thread>
int calcInt(int ctr)
{
MMETER_FUNC_PROFILER;
int val = 0;
for (int i = 0; i <= ctr; i++)
{
val += i;
}
return val;
}
int calcFloat(int ctr)
{
MMETER_FUNC_PROFILER;
float val = 0;
for (int i = 0; i <= ctr; i++)
{
val += i;
}
return val;
}
std::string calcString(int ctr)
{
MMETER_FUNC_PROFILER;
std::stringstream ss;
for (int i = 0; i <= ctr; i++)
{
ss << i << ' ';
}
return ss.str();
}
double calcNumbers(int ctr)
{
MMETER_FUNC_PROFILER;
return (calcInt(ctr) + calcFloat(ctr));
}
double calcAll(int ctr)
{
MMETER_FUNC_PROFILER;
calcString(ctr);
return (calcInt(ctr) + calcFloat(ctr));
}
void test()
{
MMETER_FUNC_PROFILER;
int COUNT = 50000000;
calcNumbers(COUNT);
calcAll(COUNT);
}
int main()
{
std::thread t1([]() {
MMETER_SCOPE_PROFILER("main function subthread");
test();
});
t1.join();
std::cout << std::fixed << std::setprecision(6) << MMeter::getGlobalTreePtr()->totalsByDurationStr() << std::endl;
std::cout << *MMeter::getGlobalTreePtr() << std::endl;
MMeter::getGlobalTreePtr()->outputBranchPercentagesToOStream(std::cout);
}