chromium/third_party/leveldatabase/src/benchmarks/db_bench.cc

// 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.

#include <sys/types.h>

#include <atomic>
#include <cstdio>
#include <cstdlib>

#include "leveldb/cache.h"
#include "leveldb/comparator.h"
#include "leveldb/db.h"
#include "leveldb/env.h"
#include "leveldb/filter_policy.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"

// Comma-separated list of operations to run in the specified order
//   Actual benchmarks:
//      fillseq       -- write N values in sequential key order in async mode
//      fillrandom    -- write N values in random key order in async mode
//      overwrite     -- overwrite N values in random key order in async mode
//      fillsync      -- write N/100 values in random key order in sync mode
//      fill100K      -- write N/1000 100K values in random order in async mode
//      deleteseq     -- delete N keys in sequential order
//      deleterandom  -- delete N keys in random order
//      readseq       -- read N times sequentially
//      readreverse   -- read N times in reverse order
//      readrandom    -- read N times in random order
//      readmissing   -- read N missing keys in random order
//      readhot       -- read N times in random order from 1% section of DB
//      seekrandom    -- N random seeks
//      seekordered   -- N ordered seeks
//      open          -- cost of opening a DB
//      crc32c        -- repeated crc32c of 4K of data
//   Meta operations:
//      compact     -- Compact the entire DB
//      stats       -- Print DB stats
//      sstables    -- Print sstable info
//      heapprofile -- Dump a heap profile (if supported by this port)
static const char* FLAGS_benchmarks =;

// Number of key/values to place in database
static int FLAGS_num =;

// Number of read operations to do.  If negative, do FLAGS_num reads.
static int FLAGS_reads =;

// Number of concurrent threads to run.
static int FLAGS_threads =;

// Size of each value
static int FLAGS_value_size =;

// Arrange to generate values that shrink to this fraction of
// their original size after compression
static double FLAGS_compression_ratio =;

// Print histogram of operation timings
static bool FLAGS_histogram =;

// Count the number of string comparisons performed
static bool FLAGS_comparisons =;

// Number of bytes to buffer in memtable before compacting
// (initialized to default value by "main")
static int FLAGS_write_buffer_size =;

// Number of bytes written to each file.
// (initialized to default value by "main")
static int FLAGS_max_file_size =;

// Approximate size of user data packed per block (before compression.
// (initialized to default value by "main")
static int FLAGS_block_size =;

// Number of bytes to use as a cache of uncompressed data.
// Negative means use default settings.
static int FLAGS_cache_size =;

// Maximum number of files to keep open at the same time (use default if == 0)
static int FLAGS_open_files =;

// Bloom filter bits per key.
// Negative means use default settings.
static int FLAGS_bloom_bits =;

// Common key prefix length.
static int FLAGS_key_prefix =;

// If true, do not destroy the existing database.  If you set this
// flag and also specify a benchmark that wants a fresh database, that
// benchmark will fail.
static bool FLAGS_use_existing_db =;

// If true, reuse existing log/MANIFEST files when re-opening a database.
static bool FLAGS_reuse_logs =;

// If true, use compression.
static bool FLAGS_compression =;

// Use the db with the following name.
static const char* FLAGS_db =;

// ZSTD compression level to try out
static int FLAGS_zstd_compression_level =;

namespace leveldb {

namespace {
leveldb::Env* g_env =;

class CountComparator : public Comparator {};

// Helper for quickly generating random data.
class RandomGenerator {};

class KeyBuffer {};

#if defined(__linux)
static Slice TrimSpace(Slice s) {}
#endif

static void AppendWithSpace(std::string* str, Slice msg) {}

class Stats {};

// State shared by all concurrent executions of the same benchmark.
struct SharedState {};

// Per-thread state for concurrent executions of the same benchmark.
struct ThreadState {};

void Compress(
    ThreadState* thread, std::string name,
    std::function<bool(const char*, size_t, std::string*)> compress_func) {}

void Uncompress(
    ThreadState* thread, std::string name,
    std::function<bool(const char*, size_t, std::string*)> compress_func,
    std::function<bool(const char*, size_t, char*)> uncompress_func) {}

}  // namespace

class Benchmark {};

}  // namespace leveldb

int main(int argc, char** argv) {}