-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
39 lines (31 loc) · 1.07 KB
/
example.cpp
File metadata and controls
39 lines (31 loc) · 1.07 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
#include <iostream>
#include <iomanip>
#include <math.h>
#include <ctime>
#include "profiler.h"
using namespace std;
void func1() {
PROFILER_TASK(func1);
float f = 0;
for (int i = 0; i < 100000; ++i) {
f += cosf(static_cast<float>(rand()));
}
cout << "fun1 output: " << fixed << setprecision(2) << f << endl;
}
void func2() {
PROFILER_TASK(func2);
float f = 0;
for (int i = 0; i < 500000; ++i) {
f += cosf(static_cast<float>(rand()));
}
cout << "fun2 output: " << fixed << setprecision(2) << f << endl;
func1();
}
int main() {
srand(time(NULL));
func1();
func2();
cout << "\n";
cout << "- func1: \n\tnum_calls: " << PROFILER_GET(func1).count << "\n\ttotal_time_passed: " << PROFILER_GET(func1).time_pass << " microsecond" << "\n\tlast_execution_time: " << PROFILER_GET(func1).last_time_pass << " microsecond\n";
cout << "- func2: \n\tnum_calls: " << PROFILER_GET(func2).count << "\n\ttotal_time_passed: " << PROFILER_GET(func2).time_pass << " microsecond" << "\n\tlast_execution_time: " << PROFILER_GET(func2).last_time_pass << " microsecond\n";
}