From a1b5650a75230d4d615ef17c21ff757bdf78d3f9 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Mon, 23 Jun 2014 10:46:16 -0700 Subject: [PATCH] db_bench: sanity check on compression ratio Summary: as requested by mark Test Plan: make release Reviewers: sdong, haobo Reviewed By: haobo Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D19221 --- db/db_bench.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/db/db_bench.cc b/db/db_bench.cc index 6e61ce0a8..7378a3cef 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -837,6 +837,15 @@ class Benchmark { int64_t writes_; int64_t readwrites_; int64_t merge_keys_; + + bool SanityCheck() { + if (FLAGS_compression_ratio > 1) { + fprintf(stderr, "compression_ratio should be between 0 and 1\n"); + return false; + } + return true; + } + void PrintHeader() { PrintEnvironment(); fprintf(stdout, "Keys: %d bytes each\n", FLAGS_key_size); @@ -1116,6 +1125,9 @@ class Benchmark { } void Run() { + if (!SanityCheck()) { + exit(1); + } PrintHeader(); Open(); const char* benchmarks = FLAGS_benchmarks.c_str();