diff --git a/db/db_bench.cc b/db/db_bench.cc index 085039cc5cd16edf7e72b28bfe805d12839c957e..efb6f210f87a7c86d87ec6abfb304aa3ffe174ff 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -1994,7 +1994,12 @@ class Benchmark { char msg[100]; snprintf(msg, sizeof(msg), "(%" PRIu64 " of %" PRIu64 " found)", found, reads_); + thread->stats.AddMessage(msg); + + if (FLAGS_perf_level > 0) { + thread->stats.AddMessage(perf_context.ToString()); + } } void PrefixScanRandom(ThreadState* thread) { diff --git a/include/rocksdb/perf_context.h b/include/rocksdb/perf_context.h index 551ca8fe667ba56930eb6fed07504183f11030cb..61adad6b73aa5343fccfb422bcb8e5a36cc2019d 100644 --- a/include/rocksdb/perf_context.h +++ b/include/rocksdb/perf_context.h @@ -7,6 +7,7 @@ #define STORAGE_ROCKSDB_INCLUDE_PERF_CONTEXT_H #include +#include namespace rocksdb { @@ -26,6 +27,8 @@ struct PerfContext { void Reset(); // reset all performance counters to zero + std::string ToString() const; + uint64_t user_key_comparison_count; // total number of user key comparisons uint64_t block_cache_hit_count; // total number of block cache hits uint64_t block_read_count; // total number of block reads (with IO) diff --git a/util/perf_context.cc b/util/perf_context.cc index 6833f6836a2e35aa891d6826402e3aa8a8642c98..650abebca075a6b796cfe7041781d65c0c0eb810 100644 --- a/util/perf_context.cc +++ b/util/perf_context.cc @@ -3,6 +3,8 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. // + +#include #include "util/perf_context_imp.h" namespace rocksdb { @@ -38,6 +40,35 @@ void PerfContext::Reset() { write_memtable_time = 0; } +#define OUTPUT(counter) #counter << " = " << counter << ", " + +std::string PerfContext::ToString() const { + std::ostringstream ss; + ss << OUTPUT(user_key_comparison_count) + << OUTPUT(block_cache_hit_count) + << OUTPUT(block_read_count) + << OUTPUT(block_read_byte) + << OUTPUT(block_read_time) + << OUTPUT(block_checksum_time) + << OUTPUT(block_decompress_time) + << OUTPUT(internal_key_skipped_count) + << OUTPUT(internal_delete_skipped_count) + << OUTPUT(write_wal_time) + << OUTPUT(get_snapshot_time) + << OUTPUT(get_from_memtable_time) + << OUTPUT(get_from_memtable_count) + << OUTPUT(get_post_process_time) + << OUTPUT(get_from_output_files_time) + << OUTPUT(seek_child_seek_time) + << OUTPUT(seek_child_seek_count) + << OUTPUT(seek_min_heap_time) + << OUTPUT(seek_internal_seek_time) + << OUTPUT(find_next_user_entry_time) + << OUTPUT(write_pre_and_post_process_time) + << OUTPUT(write_memtable_time); + return ss.str(); +} + __thread PerfContext perf_context; }