-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (47 loc) · 953 Bytes
/
main.cpp
File metadata and controls
71 lines (47 loc) · 953 Bytes
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
#include <papiCPP.hpp>
#include <vector>
#include <list>
#include <algorithm>
#include "FreeList.hpp"
int main() {
try {
std::vector<int> v;
for (int i = 20000000; i >= 0; --i) {
v.emplace_back(i);
}
papi::event_set<
PAPI_BR_INS,
PAPI_BR_TKN,
PAPI_BR_MSP
> events;
{
events.start_counters();
std::list<int> l(v.begin(), v.end());
l.sort();
for (int& i : l) {
i = i * i;
}
l.clear();
events.stop_counters();
}
std::cout << "std::list" << std::endl;
std::cout << events << std::endl;
events.reset_counters();
{
events.start_counters();
FreeList<int> fl(v.begin(), v.end());
fl.sort();
for (int& i : fl) {
i = i * i;
}
fl.clear();
events.stop_counters();
}
std::cout << "FreeList" << std::endl;
std::cout << events << std::endl;
} catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
return -1;
}
return 0;
}