From c6bd9c80ef5038cca580191148d9b88ab505bcf6 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 14 Sep 2025 00:06:33 -0400 Subject: init --- src/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b75640d --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include + +#include + +int main(int argc, char **argv) { + if (argc < 2) { + std::println(stderr, "usage: bench "); + return 1; + } + + std::println(stderr, "starting benchmark"); + + boost::sqlite::connection connection{argv[1]}; + + std::vector 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}); + + auto value = row.current().at(0).get_text(); + } + + auto end = std::chrono::system_clock::now(); + + std::chrono::duration d = end - start; + + std::println(stderr, "selected {} keys in {} ({})", keys.size(), d, + keys.size() / d.count()); + + return 0; +} -- cgit v1.2.3