Set the value for --version, add --build_info (#10275)

Summary:
./db_bench --version
db_bench version 7.5.0

./db_bench --build_info
 (RocksDB) 7.5.0
    rocksdb_build_date: 2022-06-29 09:58:04
    rocksdb_build_git_sha: d96febeeaa
    rocksdb_build_git_tag: print_version_githash

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10275

Test Plan: run it

Reviewed By: ajkr

Differential Revision: D37524720

Pulled By: mdcallag

fbshipit-source-id: 0f6c819dbadf7b033a4a3ba2941992bb76b4ff99
main
Mark Callaghan 2 years ago committed by Facebook GitHub Bot
parent f9cfc6a808
commit 177b2fa341
  1. 16
      tools/db_bench_tool.cc

@ -104,6 +104,7 @@
using GFLAGS_NAMESPACE::ParseCommandLineFlags; using GFLAGS_NAMESPACE::ParseCommandLineFlags;
using GFLAGS_NAMESPACE::RegisterFlagValidator; using GFLAGS_NAMESPACE::RegisterFlagValidator;
using GFLAGS_NAMESPACE::SetUsageMessage; using GFLAGS_NAMESPACE::SetUsageMessage;
using GFLAGS_NAMESPACE::SetVersionString;
#ifdef ROCKSDB_LITE #ifdef ROCKSDB_LITE
#define IF_ROCKSDB_LITE(Then, Else) Then #define IF_ROCKSDB_LITE(Then, Else) Then
@ -1677,6 +1678,9 @@ DEFINE_uint32(write_batch_protection_bytes_per_key, 0,
"Size of per-key-value checksum in each write batch. Currently " "Size of per-key-value checksum in each write batch. Currently "
"only value 0 and 8 are supported."); "only value 0 and 8 are supported.");
DEFINE_bool(build_info, false,
"Print the build info via GetRocksBuildInfoAsString");
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
static Status CreateMemTableRepFactory( static Status CreateMemTableRepFactory(
@ -2843,8 +2847,8 @@ class Benchmark {
#endif #endif
void PrintEnvironment() { void PrintEnvironment() {
fprintf(stderr, "RocksDB: version %d.%d\n", fprintf(stderr, "RocksDB: version %s\n",
kMajorVersion, kMinorVersion); GetRocksVersionAsString(true).c_str());
#if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__) #if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__)
time_t now = time(nullptr); time_t now = time(nullptr);
@ -8384,6 +8388,7 @@ int db_bench_tool(int argc, char** argv) {
if (!initialized) { if (!initialized) {
SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) + SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) +
" [OPTIONS]..."); " [OPTIONS]...");
SetVersionString(GetRocksVersionAsString(true));
initialized = true; initialized = true;
} }
ParseCommandLineFlags(&argc, &argv, true); ParseCommandLineFlags(&argc, &argv, true);
@ -8469,6 +8474,13 @@ int db_bench_tool(int argc, char** argv) {
FLAGS_use_existing_db |= FLAGS_readonly; FLAGS_use_existing_db |= FLAGS_readonly;
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
if (FLAGS_build_info) {
std::string build_info;
std::cout << GetRocksBuildInfoAsString(build_info, true) << std::endl;
// Similar to --version, nothing else will be done when this flag is set
exit(0);
}
if (!FLAGS_seed) { if (!FLAGS_seed) {
uint64_t now = FLAGS_env->GetSystemClock()->NowMicros(); uint64_t now = FLAGS_env->GetSystemClock()->NowMicros();
seed_base = static_cast<int64_t>(now); seed_base = static_cast<int64_t>(now);

Loading…
Cancel
Save