forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchharness_test.cc
67 lines (57 loc) · 1.42 KB
/
benchharness_test.cc
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
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#include "util/benchharness.h"
#include <vector>
namespace rocksdb {
BENCHMARK(insertFrontVector) {
std::vector<size_t> v;
for (size_t i = 0; i < 100; i++) {
v.insert(v.begin(), i);
}
}
BENCHMARK_RELATIVE(insertBackVector) {
std::vector<size_t> v;
for (size_t i = 0; i < 100; i++) {
v.insert(v.end(), i);
}
}
BENCHMARK_N(insertFrontVector_n, n) {
std::vector<size_t> v;
for (size_t i = 0; i < n; i++) {
v.insert(v.begin(), i);
}
}
BENCHMARK_RELATIVE_N(insertBackVector_n, n) {
std::vector<size_t> v;
for (size_t i = 0; i < n; i++) {
v.insert(v.end(), i);
}
}
BENCHMARK_N(insertFrontEnd_n, n) {
std::vector<size_t> v;
for (size_t i = 0; i < n; i++) {
v.insert(v.begin(), i);
}
for (size_t i = 0; i < n; i++) {
v.insert(v.end(), i);
}
}
BENCHMARK_RELATIVE_N(insertFrontEndSuspend_n, n) {
std::vector<size_t> v;
for (size_t i = 0; i < n; i++) {
v.insert(v.begin(), i);
}
BENCHMARK_SUSPEND {
for (size_t i = 0; i < n; i++) {
v.insert(v.end(), i);
}
}
}
} // namespace rocksdb
int main(int argc, char** argv) {
rocksdb::benchmark::RunBenchmarks();
return 0;
}