-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.cpp
More file actions
35 lines (28 loc) · 727 Bytes
/
set.cpp
File metadata and controls
35 lines (28 loc) · 727 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
#include <benchmark/benchmark.h>
#include <set>
void BM_set_add_ints(benchmark::State &state) {
int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
while (state.KeepRunning()) {
std::set<int> iset;
for (auto i : arr) {
iset.insert(i);
}
}
}
BENCHMARK(BM_set_add_ints);
void BM_set_copy(benchmark::State &state) {
std::set<int> iset = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
while (state.KeepRunning()) {
auto other = iset;
(void)other;
}
}
BENCHMARK(BM_set_copy);
void BM_set_copy_one(benchmark::State &state) {
std::set<int> iset = {0};
while (state.KeepRunning()) {
auto other = iset;
(void)other;
}
}
BENCHMARK(BM_set_copy_one);