The ReadnRandomWriteRandom was always looping FLAGS_num of times.

Summary: If none of reads or writes are specified by user, then pick the FLAGS_NUM as the number of iterations in the ReadRandomWriteRandom test. If either reads or writes are defined, then use their maximum.

Test Plan: run benchmark

Reviewers: heyongqiang

Reviewed By: heyongqiang

Differential Revision: https://reviews.facebook.net/D5217
main
Dhruba Borthakur 12 years ago
parent 354a9ea089
commit 536ca698ba
  1. 9
      db/db_bench.cc

@ -373,6 +373,7 @@ class Benchmark {
WriteOptions write_options_; WriteOptions write_options_;
long reads_; long reads_;
long writes_; long writes_;
long readwrites_;
int heap_counter_; int heap_counter_;
void PrintHeader() { void PrintHeader() {
@ -473,6 +474,9 @@ class Benchmark {
entries_per_batch_(1), entries_per_batch_(1),
reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads), reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads),
writes_(FLAGS_writes < 0 ? FLAGS_num : FLAGS_writes), writes_(FLAGS_writes < 0 ? FLAGS_num : FLAGS_writes),
readwrites_((FLAGS_writes < 0 && FLAGS_reads < 0)? FLAGS_num :
((FLAGS_writes > FLAGS_reads) ? FLAGS_writes : FLAGS_reads)
),
heap_counter_(0) { heap_counter_(0) {
std::vector<std::string> files; std::vector<std::string> files;
FLAGS_env->GetChildren(FLAGS_db, &files); FLAGS_env->GetChildren(FLAGS_db, &files);
@ -999,8 +1003,7 @@ class Benchmark {
long reads_done = 0; long reads_done = 0;
long writes_done = 0; long writes_done = 0;
// the number of iterations is the larger of read_ or write_ // the number of iterations is the larger of read_ or write_
long numiter = (reads_ > writes_? reads_ : writes_); for (long i = 0; i < readwrites_; i++) {
for (long i = 0; i < numiter; i++) {
char key[100]; char key[100];
const int k = thread->rand.Next() % FLAGS_num; const int k = thread->rand.Next() % FLAGS_num;
snprintf(key, sizeof(key), "%016d", k); snprintf(key, sizeof(key), "%016d", k);
@ -1031,7 +1034,7 @@ class Benchmark {
} }
char msg[100]; char msg[100];
snprintf(msg, sizeof(msg), "( reads:%ld writes:%ld total:%ld )", snprintf(msg, sizeof(msg), "( reads:%ld writes:%ld total:%ld )",
reads_done, writes_done, numiter); reads_done, writes_done, readwrites_);
thread->stats.AddMessage(msg); thread->stats.AddMessage(msg);
} }

Loading…
Cancel
Save