-
Notifications
You must be signed in to change notification settings - Fork 18
/
example.cpp
81 lines (78 loc) · 1.76 KB
/
example.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 <deque>
#include <list>
#include <set>
#include <thread>
#include <unordered_set>
#include <vector>
#if HAS_TSL
#include <tsl/robin_set.h>
#endif
#if HAS_ABSL
#include <absl/container/flat_hash_set.h>
#include <absl/container/node_hash_set.h>
#endif
using namespace std::chrono_literals;
std::vector<int> a(4);
int main() {
{ // vector
std::vector<int> a;
for (int i = 0; i < 200; i++) {
a.push_back(i);
std::this_thread::sleep_for(1us);
}
}
{ // deque
std::deque<int> a;
for (int i = 0; i < 200; i++) {
a.push_back(i);
std::this_thread::sleep_for(1us);
}
}
{ // list
std::list<int> a;
for (int i = 0; i < 100; i++) {
a.push_back(i);
std::this_thread::sleep_for(1us);
}
}
{ // set
std::set<int> a;
for (int i = 0; i < 100; i++) {
a.insert(i);
std::this_thread::sleep_for(1us);
}
}
{ // unordered_set
std::unordered_set<int> a;
for (int i = 0; i < 100; i++) {
a.insert(i);
std::this_thread::sleep_for(1us);
}
}
#if HAS_TSL
{ // robin_set
tsl::robin_set<int> a;
for (int i = 0; i < 100; i++) {
a.insert(i);
std::this_thread::sleep_for(1us);
}
}
#endif
#if HAS_ABSL
{ // flat_hash_set
absl::flat_hash_set<int> a;
for (int i = 0; i < 100; i++) {
a.insert(i);
std::this_thread::sleep_for(1us);
}
}
{ // node_hash_set
absl::node_hash_set<int> a;
for (int i = 0; i < 100; i++) {
a.insert(i);
std::this_thread::sleep_for(1us);
}
}
#endif
return 0;
}