leveldb
Public Member Functions | Private Attributes | List of all members
leveldb::anonymous_namespace{db_bench.cc}::Stats Class Reference
Collaboration diagram for leveldb::anonymous_namespace{db_bench.cc}::Stats:
Collaboration graph
[legend]

Public Member Functions

 Stats ()
 
void Start ()
 
void Merge (const Stats &other)
 
void Stop ()
 
void AddMessage (Slice msg)
 
void FinishedSingleOp ()
 
void AddBytes (int64_t n)
 
void Report (const Slice &name)
 

Private Attributes

double start_
 
double finish_
 
double seconds_
 
int done_
 
int next_report_
 
int64_t bytes_
 
double last_op_finish_
 
Histogram hist_
 
std::string message_
 

Detailed Description

Definition at line 176 of file db_bench.cc.

Constructor & Destructor Documentation

§ Stats()

leveldb::anonymous_namespace{db_bench.cc}::Stats::Stats ( )
inline

Definition at line 189 of file db_bench.cc.

Member Function Documentation

§ AddBytes()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::AddBytes ( int64_t  n)
inline

Definition at line 250 of file db_bench.cc.

250  {
251  bytes_ += n;
252  }

§ AddMessage()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::AddMessage ( Slice  msg)
inline

Definition at line 220 of file db_bench.cc.

220  {
221  AppendWithSpace(&message_, msg);
222  }
static void AppendWithSpace(std::string *str, Slice msg)
Definition: db_bench.cc:168
Here is the call graph for this function:

§ FinishedSingleOp()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::FinishedSingleOp ( )
inline

Definition at line 224 of file db_bench.cc.

224  {
225  if (FLAGS_histogram) {
226  double now = g_env->NowMicros();
227  double micros = now - last_op_finish_;
228  hist_.Add(micros);
229  if (micros > 20000) {
230  fprintf(stderr, "long op: %.1f micros%30s\r", micros, "");
231  fflush(stderr);
232  }
233  last_op_finish_ = now;
234  }
235 
236  done_++;
237  if (done_ >= next_report_) {
238  if (next_report_ < 1000) next_report_ += 100;
239  else if (next_report_ < 5000) next_report_ += 500;
240  else if (next_report_ < 10000) next_report_ += 1000;
241  else if (next_report_ < 50000) next_report_ += 5000;
242  else if (next_report_ < 100000) next_report_ += 10000;
243  else if (next_report_ < 500000) next_report_ += 50000;
244  else next_report_ += 100000;
245  fprintf(stderr, "... finished %d ops%30s\r", done_, "");
246  fflush(stderr);
247  }
248  }
void Add(double value)
Definition: histogram.cc:44
virtual uint64_t NowMicros()=0
static bool FLAGS_histogram
Definition: db_bench.cc:81
Here is the call graph for this function:

§ Merge()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::Merge ( const Stats other)
inline

Definition at line 203 of file db_bench.cc.

203  {
204  hist_.Merge(other.hist_);
205  done_ += other.done_;
206  bytes_ += other.bytes_;
207  seconds_ += other.seconds_;
208  if (other.start_ < start_) start_ = other.start_;
209  if (other.finish_ > finish_) finish_ = other.finish_;
210 
211  // Just keep the messages from one thread
212  if (message_.empty()) message_ = other.message_;
213  }
void Merge(const Histogram &other)
Definition: histogram.cc:58
Here is the call graph for this function:

§ Report()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::Report ( const Slice name)
inline

Definition at line 254 of file db_bench.cc.

254  {
255  // Pretend at least one op was done in case we are running a benchmark
256  // that does not call FinishedSingleOp().
257  if (done_ < 1) done_ = 1;
258 
259  std::string extra;
260  if (bytes_ > 0) {
261  // Rate is computed on actual elapsed time, not the sum of per-thread
262  // elapsed times.
263  double elapsed = (finish_ - start_) * 1e-6;
264  char rate[100];
265  snprintf(rate, sizeof(rate), "%6.1f MB/s",
266  (bytes_ / 1048576.0) / elapsed);
267  extra = rate;
268  }
269  AppendWithSpace(&extra, message_);
270 
271  fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n",
272  name.ToString().c_str(),
273  seconds_ * 1e6 / done_,
274  (extra.empty() ? "" : " "),
275  extra.c_str());
276  if (FLAGS_histogram) {
277  fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str());
278  }
279  fflush(stdout);
280  }
std::string ToString() const
Definition: histogram.cc:105
static void AppendWithSpace(std::string *str, Slice msg)
Definition: db_bench.cc:168
static bool FLAGS_histogram
Definition: db_bench.cc:81
Here is the call graph for this function:

§ Start()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::Start ( )
inline

§ Stop()

void leveldb::anonymous_namespace{db_bench.cc}::Stats::Stop ( )
inline

Definition at line 215 of file db_bench.cc.

Here is the call graph for this function:

Member Data Documentation

§ bytes_

int64_t leveldb::anonymous_namespace{db_bench.cc}::Stats::bytes_
private

Definition at line 183 of file db_bench.cc.

§ done_

int leveldb::anonymous_namespace{db_bench.cc}::Stats::done_
private

Definition at line 181 of file db_bench.cc.

§ finish_

double leveldb::anonymous_namespace{db_bench.cc}::Stats::finish_
private

Definition at line 179 of file db_bench.cc.

§ hist_

Histogram leveldb::anonymous_namespace{db_bench.cc}::Stats::hist_
private

Definition at line 185 of file db_bench.cc.

§ last_op_finish_

double leveldb::anonymous_namespace{db_bench.cc}::Stats::last_op_finish_
private

Definition at line 184 of file db_bench.cc.

§ message_

std::string leveldb::anonymous_namespace{db_bench.cc}::Stats::message_
private

Definition at line 186 of file db_bench.cc.

§ next_report_

int leveldb::anonymous_namespace{db_bench.cc}::Stats::next_report_
private

Definition at line 182 of file db_bench.cc.

§ seconds_

double leveldb::anonymous_namespace{db_bench.cc}::Stats::seconds_
private

Definition at line 180 of file db_bench.cc.

§ start_

double leveldb::anonymous_namespace{db_bench.cc}::Stats::start_
private

Definition at line 178 of file db_bench.cc.


The documentation for this class was generated from the following file: