Compare commits

...

2 Commits

Author SHA1 Message Date
95c66c3f47
add fmt and rocksdb in dependencies (support for older GCC versions) 2025-08-28 15:38:00 +08:00
b2b4f72524
use github repo 2025-08-27 16:29:50 +08:00
4 changed files with 21 additions and 11 deletions

View File

@ -4,8 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
# mace = { git = "https://git.o2c.fun/abby/mace.git", branch = "task-64-1" }
mace = { path = "/home/workspace/gits/github/mace"}
mace = { git = "https://github.com/abbycin/mace" }
clap = { version = "4.5.42", features = ["derive"] }
rand = "0.9.2"
log = "0.4.22"

View File

@ -10,12 +10,14 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
find_package(CLI11 CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(RocksDB CONFIG REQUIRED)
add_executable(rocksdb_bench main.cpp
instant.h)
target_include_directories(rocksdb_bench PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(rocksdb_bench rocksdb CLI11::CLI11)
target_link_libraries(rocksdb_bench PRIVATE RocksDB::rocksdb CLI11::CLI11 fmt::fmt)
file(GLOB ALL_SOURCE_FILES *.cpp *.h)
add_custom_target(format

View File

@ -1,6 +1,6 @@
#include <algorithm>
#include <atomic>
#include <print>
#include <fmt/format.h>
#include <random>
#include <rocksdb/cache.h>
#include <rocksdb/db.h>
@ -52,27 +52,27 @@ int main(int argc, char *argv[]) {
CLI11_PARSE(app, argc, argv);
if (args.path.empty()) {
std::println("path is empty");
fmt::println("path is empty");
return 1;
}
if (std::filesystem::exists(args.path)) {
std::println("path `{}` already exists", args.path);
fmt::println("path `{}` already exists", args.path);
return 1;
}
if (args.mode != "insert" && args.mode != "get" && args.mode != "mixed") {
std::println("Error: Invalid mode");
fmt::println("Error: Invalid mode");
return 1;
}
if (args.key_size < 16 || args.value_size < 16) {
std::println("Error: key_size or value_size too small, must >= 16");
fmt::println("Error: key_size or value_size too small, must >= 16");
return 1;
}
if (args.insert_ratio > 100) {
std::println("Error: Insert ratio must be between 0 and 100");
fmt::println("Error: Insert ratio must be between 0 and 100");
return 1;
}
@ -181,7 +181,7 @@ int main(int argc, char *argv[]) {
return args.mode == "insert" ? 100 : 0;
}();
double ops = static_cast<double>(total_op.load(std::memory_order_relaxed)) / b.elapse_sec();
std::println("{},{},{},{},{},{:.2f},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, ops,
fmt::println("{},{},{},{},{},{:.2f},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, ops,
b.elapse_ms());
delete db;
std::filesystem::remove_all(args.path);

View File

@ -1,5 +1,14 @@
{
"dependencies": [
"cli11"
"cli11",
"rocksdb",
"fmt"
],
"builtin-baseline": "120deac3062162151622ca4860575a33844ba10b",
"overrides": [
{
"name": "rocksdb",
"version": "10.4.2"
}
]
}