diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 88807d873..b2b52a2a5 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -459,6 +459,7 @@ DEFINE_bool(verify_checksum, false, "Verify checksum for every block read" " from storage"); DEFINE_bool(statistics, false, "Database statistics"); +DEFINE_string(statistics_string, "", "Serialized statistics string"); static class std::shared_ptr dbstats; DEFINE_int64(writes, -1, "Number of write operations to do. If negative, do" @@ -4878,6 +4879,24 @@ int db_bench_tool(int argc, char** argv) { ParseCommandLineFlags(&argc, &argv, true); FLAGS_compaction_style_e = (rocksdb::CompactionStyle) FLAGS_compaction_style; +#ifndef ROCKSDB_LITE + if (FLAGS_statistics && !FLAGS_statistics_string.empty()) { + fprintf(stderr, + "Cannot provide both --statistics and --statistics_string.\n"); + exit(1); + } + if (!FLAGS_statistics_string.empty()) { + std::unique_ptr custom_stats_guard; + dbstats.reset(NewCustomObject(FLAGS_statistics_string, + &custom_stats_guard)); + custom_stats_guard.release(); + if (dbstats == nullptr) { + fprintf(stderr, "No Statistics registered matching string: %s\n", + FLAGS_statistics_string.c_str()); + exit(1); + } + } +#endif // ROCKSDB_LITE if (FLAGS_statistics) { dbstats = rocksdb::CreateDBStatistics(); }