forked from learnedsystems/SOSD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.cc
More file actions
136 lines (110 loc) · 4.99 KB
/
Copy pathbenchmark.cc
File metadata and controls
136 lines (110 loc) · 4.99 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "benchmark.h"
#include "util.h"
#include "utils/cxxopts.hpp"
#include "competitors/oracle.h"
#include "competitors/binary_search.h"
#include "competitors/interpolation_search.h"
#include "competitors/rmi_search.h"
#include "competitors/radix_binary_search.h"
#include "competitors/spline/radix_spline.h"
#include "competitors/art.h"
#include "competitors/art32.h"
#include "competitors/fast.h"
#include "competitors/stx_btree.h"
#include "competitors/rm_tip.h"
using namespace std;
#define NAME2(a, b) NAME2_HIDDEN(a,b)
#define NAME2_HIDDEN(a, b) a ## b
#define NAME3(a, b, c) NAME3_HIDDEN(a,b,c)
#define NAME3_HIDDEN(a, b, c) a ## b ## c
#define NAME5(a, b, c, d, e) NAME5_HIDDEN(a,b,c,d,e)
#define NAME5_HIDDEN(a, b, c, d, e) a ## b ## c ## d ## e
#define run_rmi_linear(dtype, name, suffix) if (filename.find("/" #name "_" #dtype) != std::string::npos) { benchmark.Run<RMI_L<NAME2(dtype, _t), NAME5(name, _, dtype, _, suffix)::BUILD_TIME_NS, NAME5(name, _, dtype, _,suffix)::RMI_SIZE, NAME5(name, _, dtype, _,suffix)::NAME, NAME5(name, _, dtype, _, suffix)::lookup>>(); }
#define run_rmi_binary(dtype, name, suffix) if (filename.find("/" #name "_" #dtype) != std::string::npos) { benchmark.Run<RMI_B<NAME2(dtype, _t), NAME5(name, _, dtype, _, suffix)::BUILD_TIME_NS, NAME5(name, _, dtype, _, suffix)::RMI_SIZE, NAME5(name, _, dtype, _,suffix)::NAME, NAME5(name, _, dtype, _, suffix)::lookup>>(); }
int main(int argc, char* argv[]) {
cxxopts::Options options("benchmark", "Searching on sorted data benchmark");
options.positional_help("<data> <lookups>");
options.add_options()
("data", "Data file with keys", cxxopts::value<std::string>())
("lookups", "Lookup key (query) file", cxxopts::value<std::string>())
("help", "Displays help")
("r,repeats",
"Number of repeats",
cxxopts::value<int>()->default_value("1"))
("p,perf", "Track performance counters")
("b,build", "Only measure and report build times")
("histogram", "Measure each lookup and output histogram data")
("positional",
"extra positional arguments",
cxxopts::value<std::vector<std::string>>());
options.parse_positional({"data", "lookups", "positional"});
const auto result = options.parse(argc, argv);
if (result.count("help")) {
std::cout << options.help({}) << "\n";
exit(0);
}
const size_t num_repeats = result["repeats"].as<int>();
cout << "Repeating lookup code " << num_repeats << " time(s)." << endl;
const bool perf = result.count("perf");
const bool build = result.count("build");
const bool histogram = result.count("histogram");
const std::string filename = result["data"].as<std::string>();
const std::string lookups = result["lookups"].as<std::string>();
const DataType type = util::resolve_type(filename);
if (lookups.find("lookups")==std::string::npos) {
cerr
<< "Warning: lookups file seems misnamed. Did you specify the right one?\n";
}
// Pin main thread to core 0.
util::set_cpu_affinity(0);
switch (type) {
case DataType::UINT32: {
// Create benchmark.
sosd::Benchmark<uint32_t>
benchmark(filename, lookups, num_repeats, perf, build, histogram);
// Build and probe individual indexes.
benchmark.Run<OracleSearch<uint32_t>, true>();
// RMIs
run_rmi_linear(uint32, normal_200M, rmi);
run_rmi_linear(uint32, lognormal_200M, rmi);
run_rmi_binary(uint32, books_200M, rmi);
run_rmi_binary(uint32, fb_200M, rmi);
run_rmi_linear(uint32, uniform_dense_200M, rmi);
run_rmi_linear(uint32, uniform_sparse_200M, rmi);
benchmark.Run<RadixSpline<uint32_t>>();
benchmark.Run<BinarySearch<uint32_t>>();
benchmark.Run<InterpolationSearch<uint32_t>>();
benchmark.Run<RadixBinarySearch<uint32_t>>();
benchmark.Run<Fast>();
benchmark.Run<ART32>();
benchmark.Run<RMThreePointInterpolationSearch<uint32_t>>();
benchmark.Run<STXBTree<uint32_t>>();
break;
}
case DataType::UINT64: {
// Create benchmark.
sosd::Benchmark<uint64_t>
benchmark(filename, lookups, num_repeats, perf, build, histogram);
// Build and probe individual indexes.
benchmark.Run<OracleSearch<uint64_t>, true>();
// RMIs
run_rmi_binary(uint64, wiki_ts_200M, rmi);
run_rmi_binary(uint64, osm_cellids_200M, rmi);
run_rmi_linear(uint64, normal_200M, rmi);
run_rmi_binary(uint64, lognormal_200M, rmi);
run_rmi_binary(uint64, books_200M, rmi);
run_rmi_binary(uint64, fb_200M, rmi);
run_rmi_linear(uint64, uniform_dense_200M, rmi);
run_rmi_linear(uint64, uniform_sparse_200M, rmi);
benchmark.Run<RadixSpline<uint64_t>>();
benchmark.Run<RadixBinarySearch<uint64_t>>();
benchmark.Run<ART>();
benchmark.Run<BinarySearch<uint64_t>>();
benchmark.Run<InterpolationSearch<uint64_t>>();
benchmark.Run<RMThreePointInterpolationSearch<uint64_t>>();
benchmark.Run<STXBTree<uint64_t>>();
break;
}
}
return 0;
}