/
smychkov
/
SStorage
Обзор
Документация
Войти
/
smychkov
/
SStorage
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
bench/bench_put.cpp
44 строки
1 KB
Андрей Смычков
chore: benchmarks + docs update + remove CMakeLists.txt + legacy data
25 апр 2026, 09:25
25 апр 2026, 09:25
66c16af
Код
Авторство
О чём код?
//============================================================================ // Бенчмарк: throughput put-операций //============================================================================ #include "../src/core/database.hpp" #include <chrono> #include <cstdio> #include <cstdlib> #include <filesystem> #include <iostream> #include <string> #include <sys/stat.h> #include <unistd.h> using namespace sstorage; int main(int argc, char** argv) { const int kOps = argc > 1 ? std::atoi(argv[1]) : 100000; std::string dir = "/tmp/sstorage_bench_put_" + std::to_string(::getpid()); ::mkdir(dir.c_str(), 0755); Config cfg; cfg.setDataDirectory(dir); Database db(cfg); db.open(); auto start = std::chrono::steady_clock::now(); for (int i = 0; i < kOps; ++i) { char k[32]; std::snprintf(k, sizeof(k), "key_%08d", i); db.put(k, "value_payload_here_1234567890"); } db.flush(); auto end = std::chrono::steady_clock::now(); db.close(); double sec = std::chrono::duration<double>(end - start).count(); std::cout << "bench_put: " << kOps << " ops in " << sec << "s = " << (kOps / sec) << " ops/sec\n"; std::error_code ec; std::filesystem::remove_all(dir, ec); return 0; }