blob: 2bd472fbbe7367077e28c44c665b18162f7e277c (
plain)
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
|
#include <chrono>
#include <iostream>
#include <print>
#include <string>
#include <vector>
#include <boost/sqlite.hpp>
int main(int argc, char **argv) {
if (argc < 2) {
std::println(stderr, "usage: bench <database>");
return 1;
}
std::println(stderr, "starting benchmark");
boost::sqlite::connection connection{argv[1]};
std::vector<std::string> keys;
std::string line;
while (std::getline(std::cin, line)) {
keys.push_back(line);
}
std::println(stderr, "slurped {} keys into memory", keys.size());
auto start = std::chrono::system_clock::now();
auto st = connection.prepare("select kv.value from kv where kv.key=?");
for (const auto &key : keys) {
auto row = st.execute({key});
[[maybe_unused]]
auto value = row.current().at(0).get_text();
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> d = end - start;
std::println(stderr, "selected {} keys in {} ({})", keys.size(), d,
keys.size() / d.count());
return 0;
}
|