diff --git a/src/test/bench_test/benchmark.cpp b/src/test/bench_test/benchmark.cpp index 01a729a383..1fb384a654 100644 --- a/src/test/bench_test/benchmark.cpp +++ b/src/test/bench_test/benchmark.cpp @@ -158,18 +158,17 @@ void benchmark::multi_set_random(thread_arg *thread) { // do write operation num times uint64_t bytes = 0; - int count = 0; - for (int i = 0; i < config::instance().num / 100; i++) { + for (int i = 0; i < FLAGS_benchmark_num / 100; i++) { // generate hash key std::string hash_key, sort_key, value; - hash_key = generate_string(config::instance().hashkey_size); + hash_key = generate_string(FLAGS_hashkey_size); std::map kvs; // generate sort key and value for (int j = 0; j < 100; j++) { - sort_key = generate_string(config::instance().sortkey_size); - value = generate_string(config::instance().value_size); + sort_key = generate_string(FLAGS_sortkey_size); + value = generate_string(FLAGS_value_size); kvs.emplace(sort_key, value); } @@ -177,12 +176,9 @@ void benchmark::multi_set_random(thread_arg *thread) int try_count = 0; while (true) { try_count++; - int ret = _client->multi_set(hash_key, kvs, config::instance().pegasus_timeout_ms); + int ret = _client->multi_set(hash_key, kvs, FLAGS_pegasus_timeout_ms); if (ret == ::pegasus::PERR_OK) { - bytes += (config::instance().value_size + config::instance().hashkey_size + - config::instance().sortkey_size) * - 100; - count += 100; + bytes += (FLAGS_value_size + FLAGS_hashkey_size + FLAGS_sortkey_size) * 100; break; } else if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) { fmt::print(stderr, "Set returned an error: {}\n", _client->get_error_string(ret)); @@ -243,31 +239,34 @@ void benchmark::multi_get_random(thread_arg *thread) { uint64_t bytes = 0; uint64_t found = 0; - for (int i = 0; i < config::instance().num / 100; i++) { + int max_fetch_count = 100; + int max_fetch_size = 1000000; + + for (int i = 0; i < FLAGS_benchmark_num / 100; i++) + { // generate hash key - std::string hash_key, sort_key, value; - hash_key = generate_string(config::instance().hashkey_size); + std::string hashkey, sort_key, value; + hashkey = generate_string(FLAGS_hashkey_size); std::map kvs; std::set sortkeys; // generate sort key // generate value for random to keep in peace with write for (int j = 0; j < 100; j++) { - sortkeys.insert(generate_string(config::instance().sortkey_size)); - value = generate_string(config::instance().value_size); + sortkeys.insert(generate_string(FLAGS_sortkey_size)); + value = generate_string(FLAGS_value_size); } // read from pegasus int try_count = 0; while (true) { try_count++; - int ret = _client->multi_get(hash_key, sortkeys, kvs); + int ret = _client->multi_get( + hashkey, sortkeys, kvs, max_fetch_count, max_fetch_size, FLAGS_pegasus_timeout_ms); if (ret == ::pegasus::PERR_OK) { found += 100; - bytes += (config::instance().value_size + config::instance().hashkey_size + - config::instance().sortkey_size) * - 100; + bytes += (FLAGS_hashkey_size + FLAGS_sortkey_size + FLAGS_value_size) * 100; break; } else if (ret == ::pegasus::PERR_NOT_FOUND) { break; @@ -284,7 +283,7 @@ void benchmark::multi_get_random(thread_arg *thread) } // count total read bytes and hit rate - std::string msg = fmt::format("({} of {} found)", found, config::instance().num); + std::string msg = fmt::format("({} of {} found)", found, FLAGS_benchmark_num); thread->stats.add_bytes(bytes); thread->stats.add_message(msg); }