// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
-
+//
//The test uses an array to compare against values written to the database.
//Keys written to the array are in 1:1 correspondence to the actual values in
//the database according to the formula in the functino GenerateValue
//the positions in the array. Therefore to shorten/elongate the amount of time
//that this test runs for, you should change the settings:
//FLAGS_max_key, FLAGS_ops_per_thread, (sometimes also FLAGS_threads)
+//NOTE that if FLAGS_test_batches_snapshots is set, the test behaves a little
+//differently. See comment header for the flag.
#include <sys/types.h>
#include <stdio.h>
long done_;
long writes_;
long deletes_;
+ long gets_;
long founds_;
long errors_;
int next_report_;
done_ = 0;
writes_ = 0;
deletes_ = 0;
+ gets_ = 0;
founds_ = 0;
errors_ = 0;
bytes_ = 0;
done_ += other.done_;
writes_ += other.writes_;
deletes_ += other.deletes_;
+ gets_ += other.gets_;
+ founds_ += other.founds_;
+ errors_ += other.errors_;
bytes_ += other.bytes_;
seconds_ += other.seconds_;
if (other.start_ < start_) start_ = other.start_;
deletes_ += n;
}
- void AddFounds(int n) {
- founds_ += n;
+ void AddGets(int ngets, int nfounds) {
+ founds_ += nfounds;
+ gets_ += ngets;
}
void AddErrors(int n) {
seconds_ * 1e6 / done_, (long)throughput);
fprintf(stdout, "%-12s: Wrote %.2f MB (%.2f MB/sec) (%ld%% of %ld ops)\n",
"", bytes_mb, rate, (100*writes_)/done_, done_);
+ fprintf(stdout, "%-12s: Wrote %ld times\n", "", writes_);
fprintf(stdout, "%-12s: Deleted %ld times\n", "", deletes_);
- fprintf(stdout, "%-12s: Found lookups %ld times\n", "", founds_);
+ fprintf(stdout, "%-12s: %ld/%ld gets found the key\n", "", founds_, gets_);
fprintf(stdout, "%-12s: Got errors %ld times\n", "", errors_);
if (FLAGS_histogram) {
}
now = FLAGS_env->NowMicros();
- fprintf(stdout, "%s Starting verification\n",
- FLAGS_env->TimeToString((uint64_t) now/1000000).c_str());
+ if (FLAGS_test_batches_snapshots) {
+ fprintf(stdout, "%s Limited verification already done during gets\n",
+ FLAGS_env->TimeToString((uint64_t) now/1000000).c_str());
+ } else {
+ fprintf(stdout, "%s Starting verification\n",
+ FLAGS_env->TimeToString((uint64_t) now/1000000).c_str());
+ }
shared.SetStartVerify();
shared.GetCondVar()->SignalAll();
threads[i] = nullptr;
}
double now = FLAGS_env->NowMicros();
- fprintf(stdout, "%s Verification successful\n",
- FLAGS_env->TimeToString((uint64_t) now/1000000).c_str());
-
+ if (!FLAGS_test_batches_snapshots) {
+ fprintf(stdout, "%s Verification successful\n",
+ FLAGS_env->TimeToString((uint64_t) now/1000000).c_str());
+ }
PrintStatistics();
}
// find more errors if any
} else if (s.IsNotFound()) {
values[i] = "";
+ thread->stats.AddGets(1, 0);
} else {
values[i] = *value;
expected_prefix, actual_prefix);
}
(values[i])[0] = ' '; // blank out the differing character
- thread->stats.AddFounds(1);
+ thread->stats.AddGets(1, 1);
}
}
db_->ReleaseSnapshot(readoptionscopy.snapshot);
else {
thread->shared->GetCondVar()->Wait();
}
- thread->stats.Start();
+ // Commenting this out as we don't want to reset stats on each open.
+ // thread->stats.Start();
}
}
unsigned int probability_operation = thread->rand.Uniform(100);
if (probability_operation < FLAGS_readpercent) {
// read load
- FLAGS_test_batches_snapshots ?
- MultiGet(thread, read_opts, key, &from_db) :
- db_->Get(read_opts, key, &from_db);
+ if (!FLAGS_test_batches_snapshots) {
+ Status s = db_->Get(read_opts, key, &from_db);
+ if (s.ok()) {
+ // found case
+ thread->stats.AddGets(1, 1);
+ } else if (s.IsNotFound()) {
+ // not found case
+ thread->stats.AddGets(1, 0);
+ } else {
+ // errors case
+ thread->stats.AddErrors(1);
+ }
+ } else {
+ MultiGet(thread, read_opts, key, &from_db);
+ }
} else if (probability_operation < FLAGS_delpercent + FLAGS_readpercent) {
//introduce delete load
if (!FLAGS_test_batches_snapshots) {