-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
124 lines (95 loc) · 2 KB
/
main.cpp
File metadata and controls
124 lines (95 loc) · 2 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// Created by Kazem on 2023-04-11.
//
#include <iostream>
#include <benchmark/benchmark.h>
struct Inputs{
};
struct Outputs{
};
struct Stats{
};
class TestingBench{
protected:
Inputs *In;
Outputs *Out;
Stats *St;
virtual void setup(){
std::cout<<"TestingBench::setup()"<<std::endl;
}
virtual void inspect(){
std::cout<<"TestingBench::analysis()"<<std::endl;
}
virtual double test(){
std::cout<<"TestingBench::test()"<<std::endl;
}
virtual void teardown(){
std::cout<<"TestingBench::teardown()"<<std::endl;
}
public:
TestingBench(Inputs *In1, Outputs *Out1, Stats *St1):
In(In1), Out(Out1), St(St1){}
void run(){
setup();
inspect();
test();
teardown();
}
};
class Test1: public TestingBench{
protected:
void setup() override{
std::cout<<"Test1::setup()"<<std::endl;
}
void inspect() override{
std::cout<<"Test1::analysis()"<<std::endl;
}
double test() override{
double tmp = 0;
for (int i = 0; i < 100; ++i) {
tmp = 0;
for (int j = 0; j < 100; ++j) {
tmp *= j;
}
tmp += i;
}
std::cout<<"Test1::test()"<<tmp<<std::endl;
}
void teardown() override {
std::cout<<"Test1::teardown()"<<std::endl;
}
public:
Test1(Inputs *In1, Outputs *Out1, Stats *St1):
TestingBench(In1, Out1, St1){}
};
static void bmSomeFunction(benchmark::State& State) {
// Perform setup here
for (auto _ : State) {
// This code gets timed
double tmp = 0;
for (int i = 0; i < 100; ++i) {
tmp = 0;
for (int j = 0; j < 100; ++j) {
tmp *= j;
}
tmp += i;
}
}
}
// Register the function as a benchmark
BENCHMARK(bmSomeFunction)->Unit(benchmark::kMillisecond)->Iterations(100)->Repetitions(10);
// Run the benchmark
BENCHMARK_MAIN();
//int main(const int argc, const char *argv[]) {
//
// Inputs *In = new Inputs();
// Stats *St = new Stats();
// Outputs *Out = new Outputs();
// auto TB = new TestingBench(In, Out, St);
// TB->run();
//
// std::cout<<"-----------------"<<std::endl;
// auto T1 = new Test1(In, Out, St);
// T1->run();
// return 0;
//}