leveldb
Classes | Namespaces | Functions | Variables
db_bench.cc File Reference
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "db/db_impl.h"
#include "db/version_set.h"
#include "leveldb/cache.h"
#include "leveldb/db.h"
#include "leveldb/env.h"
#include "leveldb/write_batch.h"
#include "port/port.h"
#include "util/crc32c.h"
#include "util/histogram.h"
#include "util/mutexlock.h"
#include "util/random.h"
#include "util/testutil.h"
Include dependency graph for db_bench.cc:

Go to the source code of this file.

Classes

class  leveldb::anonymous_namespace{db_bench.cc}::RandomGenerator
 
class  leveldb::anonymous_namespace{db_bench.cc}::Stats
 
struct  leveldb::anonymous_namespace{db_bench.cc}::SharedState
 
struct  leveldb::anonymous_namespace{db_bench.cc}::ThreadState
 
class  leveldb::Benchmark
 
struct  leveldb::Benchmark::ThreadArg
 

Namespaces

 leveldb
 
 leveldb::anonymous_namespace{db_bench.cc}
 

Functions

static void leveldb::anonymous_namespace{db_bench.cc}::AppendWithSpace (std::string *str, Slice msg)
 
int main (int argc, char **argv)
 

Variables

static const char * FLAGS_benchmarks
 
static int FLAGS_num = 1000000
 
static int FLAGS_reads = -1
 
static int FLAGS_threads = 1
 
static int FLAGS_value_size = 100
 
static double FLAGS_compression_ratio = 0.5
 
static bool FLAGS_histogram = false
 
static int FLAGS_write_buffer_size = 0
 
static int FLAGS_max_file_size = 0
 
static int FLAGS_block_size = 0
 
static int FLAGS_cache_size = -1
 
static int FLAGS_open_files = 0
 
static int FLAGS_bloom_bits = -1
 
static bool FLAGS_use_existing_db = false
 
static bool FLAGS_reuse_logs = false
 
static const char * FLAGS_db = NULL
 
leveldb::Envleveldb::anonymous_namespace{db_bench.cc}::g_env = NULL
 

Function Documentation

§ main()

int main ( int  argc,
char **  argv 
)

Definition at line 956 of file db_bench.cc.

956  {
961  std::string default_db_path;
962 
963  for (int i = 1; i < argc; i++) {
964  double d;
965  int n;
966  char junk;
967  if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) {
968  FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
969  } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
971  } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 &&
972  (n == 0 || n == 1)) {
973  FLAGS_histogram = n;
974  } else if (sscanf(argv[i], "--use_existing_db=%d%c", &n, &junk) == 1 &&
975  (n == 0 || n == 1)) {
977  } else if (sscanf(argv[i], "--reuse_logs=%d%c", &n, &junk) == 1 &&
978  (n == 0 || n == 1)) {
979  FLAGS_reuse_logs = n;
980  } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) {
981  FLAGS_num = n;
982  } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) {
983  FLAGS_reads = n;
984  } else if (sscanf(argv[i], "--threads=%d%c", &n, &junk) == 1) {
985  FLAGS_threads = n;
986  } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) {
987  FLAGS_value_size = n;
988  } else if (sscanf(argv[i], "--write_buffer_size=%d%c", &n, &junk) == 1) {
990  } else if (sscanf(argv[i], "--max_file_size=%d%c", &n, &junk) == 1) {
992  } else if (sscanf(argv[i], "--block_size=%d%c", &n, &junk) == 1) {
993  FLAGS_block_size = n;
994  } else if (sscanf(argv[i], "--cache_size=%d%c", &n, &junk) == 1) {
995  FLAGS_cache_size = n;
996  } else if (sscanf(argv[i], "--bloom_bits=%d%c", &n, &junk) == 1) {
997  FLAGS_bloom_bits = n;
998  } else if (sscanf(argv[i], "--open_files=%d%c", &n, &junk) == 1) {
999  FLAGS_open_files = n;
1000  } else if (strncmp(argv[i], "--db=", 5) == 0) {
1001  FLAGS_db = argv[i] + 5;
1002  } else {
1003  fprintf(stderr, "Invalid flag '%s'\n", argv[i]);
1004  exit(1);
1005  }
1006  }
1007 
1009 
1010  // Choose a location for the test database if none given with --db=<path>
1011  if (FLAGS_db == NULL) {
1012  leveldb::g_env->GetTestDirectory(&default_db_path);
1013  default_db_path += "/dbbench";
1014  FLAGS_db = default_db_path.c_str();
1015  }
1016 
1017  leveldb::Benchmark benchmark;
1018  benchmark.Run();
1019  return 0;
1020 }
static int FLAGS_threads
Definition: db_bench.cc:71
size_t write_buffer_size
Definition: options.h:83
static int FLAGS_open_files
Definition: db_bench.cc:100
static int FLAGS_value_size
Definition: db_bench.cc:74
static const char * FLAGS_db
Definition: db_bench.cc:115
static int FLAGS_reads
Definition: db_bench.cc:68
virtual Status GetTestDirectory(std::string *path)=0
size_t max_file_size
Definition: options.h:125
static const char * FLAGS_benchmarks
Definition: db_bench.cc:44
static int FLAGS_max_file_size
Definition: db_bench.cc:89
static int FLAGS_cache_size
Definition: db_bench.cc:97
static int FLAGS_write_buffer_size
Definition: db_bench.cc:85
static int FLAGS_block_size
Definition: db_bench.cc:93
static bool FLAGS_reuse_logs
Definition: db_bench.cc:112
static int FLAGS_num
Definition: db_bench.cc:65
int max_open_files
Definition: options.h:90
static bool FLAGS_use_existing_db
Definition: db_bench.cc:109
size_t block_size
Definition: options.h:106
static Env * Default()
Definition: env_posix.cc:613
static double FLAGS_compression_ratio
Definition: db_bench.cc:78
static int FLAGS_bloom_bits
Definition: db_bench.cc:104
static bool FLAGS_histogram
Definition: db_bench.cc:81
Here is the call graph for this function:

Variable Documentation

§ FLAGS_benchmarks

const char* FLAGS_benchmarks
static
Initial value:
=
"fillseq,"
"fillsync,"
"fillrandom,"
"overwrite,"
"readrandom,"
"readrandom,"
"readseq,"
"readreverse,"
"compact,"
"readrandom,"
"readseq,"
"readreverse,"
"fill100K,"
"crc32c,"
"snappycomp,"
"snappyuncomp,"
"acquireload,"

Definition at line 44 of file db_bench.cc.

§ FLAGS_block_size

int FLAGS_block_size = 0
static

Definition at line 93 of file db_bench.cc.

§ FLAGS_bloom_bits

int FLAGS_bloom_bits = -1
static

Definition at line 104 of file db_bench.cc.

§ FLAGS_cache_size

int FLAGS_cache_size = -1
static

Definition at line 97 of file db_bench.cc.

§ FLAGS_compression_ratio

double FLAGS_compression_ratio = 0.5
static

Definition at line 78 of file db_bench.cc.

§ FLAGS_db

const char* FLAGS_db = NULL
static

Definition at line 115 of file db_bench.cc.

§ FLAGS_histogram

bool FLAGS_histogram = false
static

Definition at line 81 of file db_bench.cc.

§ FLAGS_max_file_size

int FLAGS_max_file_size = 0
static

Definition at line 89 of file db_bench.cc.

§ FLAGS_num

int FLAGS_num = 1000000
static

Definition at line 65 of file db_bench.cc.

§ FLAGS_open_files

int FLAGS_open_files = 0
static

Definition at line 100 of file db_bench.cc.

§ FLAGS_reads

int FLAGS_reads = -1
static

Definition at line 68 of file db_bench.cc.

§ FLAGS_reuse_logs

bool FLAGS_reuse_logs = false
static

Definition at line 112 of file db_bench.cc.

§ FLAGS_threads

int FLAGS_threads = 1
static

Definition at line 71 of file db_bench.cc.

§ FLAGS_use_existing_db

bool FLAGS_use_existing_db = false
static

Definition at line 109 of file db_bench.cc.

§ FLAGS_value_size

int FLAGS_value_size = 100
static

Definition at line 74 of file db_bench.cc.

§ FLAGS_write_buffer_size

int FLAGS_write_buffer_size = 0
static

Definition at line 85 of file db_bench.cc.