作者: 韩晨旭 10225101440 李畅 10225102463
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

682 lines
20 KiB

  1. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. #include <sys/types.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "db/db_impl.h"
  8. #include "db/version_set.h"
  9. #include "leveldb/cache.h"
  10. #include "leveldb/db.h"
  11. #include "leveldb/env.h"
  12. #include "leveldb/write_batch.h"
  13. #include "port/port.h"
  14. #include "util/crc32c.h"
  15. #include "util/histogram.h"
  16. #include "util/random.h"
  17. #include "util/testutil.h"
  18. // Comma-separated list of operations to run in the specified order
  19. // Actual benchmarks:
  20. // fillseq -- write N values in sequential key order in async mode
  21. // fillrandom -- write N values in random key order in async mode
  22. // overwrite -- overwrite N values in random key order in async mode
  23. // fillsync -- write N/100 values in random key order in sync mode
  24. // fill100K -- write N/1000 100K values in random order in async mode
  25. // readseq -- read N times sequentially
  26. // readreverse -- read N times in reverse order
  27. // readrandom -- read N times in random order
  28. // readhot -- read N times in random order from 1% section of DB
  29. // crc32c -- repeated crc32c of 4K of data
  30. // acquireload -- load N*1000 times
  31. // Meta operations:
  32. // compact -- Compact the entire DB
  33. // stats -- Print DB stats
  34. // heapprofile -- Dump a heap profile (if supported by this port)
  35. static const char* FLAGS_benchmarks =
  36. "fillseq,"
  37. "fillsync,"
  38. "fillrandom,"
  39. "overwrite,"
  40. "readrandom,"
  41. "readrandom," // Extra run to allow previous compactions to quiesce
  42. "readseq,"
  43. "readreverse,"
  44. "compact,"
  45. "readrandom,"
  46. "readseq,"
  47. "readreverse,"
  48. "fill100K,"
  49. "crc32c,"
  50. "snappycomp,"
  51. "snappyuncomp,"
  52. "acquireload,"
  53. ;
  54. // Number of key/values to place in database
  55. static int FLAGS_num = 1000000;
  56. // Number of read operations to do. If negative, do FLAGS_num reads.
  57. static int FLAGS_reads = -1;
  58. // Size of each value
  59. static int FLAGS_value_size = 100;
  60. // Arrange to generate values that shrink to this fraction of
  61. // their original size after compression
  62. static double FLAGS_compression_ratio = 0.5;
  63. // Print histogram of operation timings
  64. static bool FLAGS_histogram = false;
  65. // Number of bytes to buffer in memtable before compacting
  66. // (initialized to default value by "main")
  67. static int FLAGS_write_buffer_size = 0;
  68. // Number of bytes to use as a cache of uncompressed data.
  69. // Negative means use default settings.
  70. static int FLAGS_cache_size = -1;
  71. // Maximum number of files to keep open at the same time (use default if == 0)
  72. static int FLAGS_open_files = 0;
  73. // If true, do not destroy the existing database. If you set this
  74. // flag and also specify a benchmark that wants a fresh database, that
  75. // benchmark will fail.
  76. static bool FLAGS_use_existing_db = false;
  77. // Use the db with the following name.
  78. static const char* FLAGS_db = "/tmp/dbbench";
  79. namespace leveldb {
  80. // Helper for quickly generating random data.
  81. namespace {
  82. class RandomGenerator {
  83. private:
  84. std::string data_;
  85. int pos_;
  86. public:
  87. RandomGenerator() {
  88. // We use a limited amount of data over and over again and ensure
  89. // that it is larger than the compression window (32KB), and also
  90. // large enough to serve all typical value sizes we want to write.
  91. Random rnd(301);
  92. std::string piece;
  93. while (data_.size() < 1048576) {
  94. // Add a short fragment that is as compressible as specified
  95. // by FLAGS_compression_ratio.
  96. test::CompressibleString(&rnd, FLAGS_compression_ratio, 100, &piece);
  97. data_.append(piece);
  98. }
  99. pos_ = 0;
  100. }
  101. Slice Generate(int len) {
  102. if (pos_ + len > data_.size()) {
  103. pos_ = 0;
  104. assert(len < data_.size());
  105. }
  106. pos_ += len;
  107. return Slice(data_.data() + pos_ - len, len);
  108. }
  109. };
  110. static Slice TrimSpace(Slice s) {
  111. int start = 0;
  112. while (start < s.size() && isspace(s[start])) {
  113. start++;
  114. }
  115. int limit = s.size();
  116. while (limit > start && isspace(s[limit-1])) {
  117. limit--;
  118. }
  119. return Slice(s.data() + start, limit - start);
  120. }
  121. }
  122. class Benchmark {
  123. private:
  124. Cache* cache_;
  125. DB* db_;
  126. int num_;
  127. int reads_;
  128. int heap_counter_;
  129. double start_;
  130. double last_op_finish_;
  131. int64_t bytes_;
  132. std::string message_;
  133. std::string post_message_;
  134. Histogram hist_;
  135. RandomGenerator gen_;
  136. Random rand_;
  137. // State kept for progress messages
  138. int done_;
  139. int next_report_; // When to report next
  140. void PrintHeader() {
  141. const int kKeySize = 16;
  142. PrintEnvironment();
  143. fprintf(stdout, "Keys: %d bytes each\n", kKeySize);
  144. fprintf(stdout, "Values: %d bytes each (%d bytes after compression)\n",
  145. FLAGS_value_size,
  146. static_cast<int>(FLAGS_value_size * FLAGS_compression_ratio + 0.5));
  147. fprintf(stdout, "Entries: %d\n", num_);
  148. fprintf(stdout, "RawSize: %.1f MB (estimated)\n",
  149. ((static_cast<int64_t>(kKeySize + FLAGS_value_size) * num_)
  150. / 1048576.0));
  151. fprintf(stdout, "FileSize: %.1f MB (estimated)\n",
  152. (((kKeySize + FLAGS_value_size * FLAGS_compression_ratio) * num_)
  153. / 1048576.0));
  154. PrintWarnings();
  155. fprintf(stdout, "------------------------------------------------\n");
  156. }
  157. void PrintWarnings() {
  158. #if defined(__GNUC__) && !defined(__OPTIMIZE__)
  159. fprintf(stdout,
  160. "WARNING: Optimization is disabled: benchmarks unnecessarily slow\n"
  161. );
  162. #endif
  163. #ifndef NDEBUG
  164. fprintf(stdout,
  165. "WARNING: Assertions are enabled; benchmarks unnecessarily slow\n");
  166. #endif
  167. // See if snappy is working by attempting to compress a compressible string
  168. const char text[] = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
  169. std::string compressed;
  170. if (!port::Snappy_Compress(text, sizeof(text), &compressed)) {
  171. fprintf(stdout, "WARNING: Snappy compression is not enabled\n");
  172. } else if (compressed.size() >= sizeof(text)) {
  173. fprintf(stdout, "WARNING: Snappy compression is not effective\n");
  174. }
  175. }
  176. void PrintEnvironment() {
  177. fprintf(stderr, "LevelDB: version %d.%d\n",
  178. kMajorVersion, kMinorVersion);
  179. #if defined(__linux)
  180. time_t now = time(NULL);
  181. fprintf(stderr, "Date: %s", ctime(&now)); // ctime() adds newline
  182. FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
  183. if (cpuinfo != NULL) {
  184. char line[1000];
  185. int num_cpus = 0;
  186. std::string cpu_type;
  187. std::string cache_size;
  188. while (fgets(line, sizeof(line), cpuinfo) != NULL) {
  189. const char* sep = strchr(line, ':');
  190. if (sep == NULL) {
  191. continue;
  192. }
  193. Slice key = TrimSpace(Slice(line, sep - 1 - line));
  194. Slice val = TrimSpace(Slice(sep + 1));
  195. if (key == "model name") {
  196. ++num_cpus;
  197. cpu_type = val.ToString();
  198. } else if (key == "cache size") {
  199. cache_size = val.ToString();
  200. }
  201. }
  202. fclose(cpuinfo);
  203. fprintf(stderr, "CPU: %d * %s\n", num_cpus, cpu_type.c_str());
  204. fprintf(stderr, "CPUCache: %s\n", cache_size.c_str());
  205. }
  206. #endif
  207. }
  208. void Start() {
  209. start_ = Env::Default()->NowMicros() * 1e-6;
  210. bytes_ = 0;
  211. message_.clear();
  212. last_op_finish_ = start_;
  213. hist_.Clear();
  214. done_ = 0;
  215. next_report_ = 100;
  216. }
  217. void FinishedSingleOp() {
  218. if (FLAGS_histogram) {
  219. double now = Env::Default()->NowMicros() * 1e-6;
  220. double micros = (now - last_op_finish_) * 1e6;
  221. hist_.Add(micros);
  222. if (micros > 20000) {
  223. fprintf(stderr, "long op: %.1f micros%30s\r", micros, "");
  224. fflush(stderr);
  225. }
  226. last_op_finish_ = now;
  227. }
  228. done_++;
  229. if (done_ >= next_report_) {
  230. if (next_report_ < 1000) next_report_ += 100;
  231. else if (next_report_ < 5000) next_report_ += 500;
  232. else if (next_report_ < 10000) next_report_ += 1000;
  233. else if (next_report_ < 50000) next_report_ += 5000;
  234. else if (next_report_ < 100000) next_report_ += 10000;
  235. else if (next_report_ < 500000) next_report_ += 50000;
  236. else next_report_ += 100000;
  237. fprintf(stderr, "... finished %d ops%30s\r", done_, "");
  238. fflush(stderr);
  239. }
  240. }
  241. void Stop(const Slice& name) {
  242. double finish = Env::Default()->NowMicros() * 1e-6;
  243. // Pretend at least one op was done in case we are running a benchmark
  244. // that does nto call FinishedSingleOp().
  245. if (done_ < 1) done_ = 1;
  246. if (bytes_ > 0) {
  247. char rate[100];
  248. snprintf(rate, sizeof(rate), "%6.1f MB/s",
  249. (bytes_ / 1048576.0) / (finish - start_));
  250. if (!message_.empty()) {
  251. message_ = std::string(rate) + " " + message_;
  252. } else {
  253. message_ = rate;
  254. }
  255. }
  256. fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n",
  257. name.ToString().c_str(),
  258. (finish - start_) * 1e6 / done_,
  259. (message_.empty() ? "" : " "),
  260. message_.c_str());
  261. if (FLAGS_histogram) {
  262. fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str());
  263. }
  264. fflush(stdout);
  265. if (!post_message_.empty()) {
  266. fprintf(stdout, "\n%s\n", post_message_.c_str());
  267. post_message_.clear();
  268. }
  269. }
  270. public:
  271. enum Order {
  272. SEQUENTIAL,
  273. RANDOM
  274. };
  275. enum DBState {
  276. FRESH,
  277. EXISTING
  278. };
  279. Benchmark()
  280. : cache_(FLAGS_cache_size >= 0 ? NewLRUCache(FLAGS_cache_size) : NULL),
  281. db_(NULL),
  282. num_(FLAGS_num),
  283. reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads),
  284. heap_counter_(0),
  285. bytes_(0),
  286. rand_(301) {
  287. std::vector<std::string> files;
  288. Env::Default()->GetChildren(FLAGS_db, &files);
  289. for (int i = 0; i < files.size(); i++) {
  290. if (Slice(files[i]).starts_with("heap-")) {
  291. Env::Default()->DeleteFile(std::string(FLAGS_db) + "/" + files[i]);
  292. }
  293. }
  294. if (!FLAGS_use_existing_db) {
  295. DestroyDB(FLAGS_db, Options());
  296. }
  297. }
  298. ~Benchmark() {
  299. delete db_;
  300. delete cache_;
  301. }
  302. void Run() {
  303. PrintHeader();
  304. Open();
  305. const char* benchmarks = FLAGS_benchmarks;
  306. while (benchmarks != NULL) {
  307. const char* sep = strchr(benchmarks, ',');
  308. Slice name;
  309. if (sep == NULL) {
  310. name = benchmarks;
  311. benchmarks = NULL;
  312. } else {
  313. name = Slice(benchmarks, sep - benchmarks);
  314. benchmarks = sep + 1;
  315. }
  316. Start();
  317. WriteOptions write_options;
  318. bool known = true;
  319. if (name == Slice("fillseq")) {
  320. Write(write_options, SEQUENTIAL, FRESH, num_, FLAGS_value_size, 1);
  321. } else if (name == Slice("fillbatch")) {
  322. Write(write_options, SEQUENTIAL, FRESH, num_, FLAGS_value_size, 1000);
  323. } else if (name == Slice("fillrandom")) {
  324. Write(write_options, RANDOM, FRESH, num_, FLAGS_value_size, 1);
  325. } else if (name == Slice("overwrite")) {
  326. Write(write_options, RANDOM, EXISTING, num_, FLAGS_value_size, 1);
  327. } else if (name == Slice("fillsync")) {
  328. write_options.sync = true;
  329. Write(write_options, RANDOM, FRESH, num_ / 1000, FLAGS_value_size, 1);
  330. } else if (name == Slice("fill100K")) {
  331. Write(write_options, RANDOM, FRESH, num_ / 1000, 100 * 1000, 1);
  332. } else if (name == Slice("readseq")) {
  333. ReadSequential();
  334. } else if (name == Slice("readreverse")) {
  335. ReadReverse();
  336. } else if (name == Slice("readrandom")) {
  337. ReadRandom();
  338. } else if (name == Slice("readhot")) {
  339. ReadHot();
  340. } else if (name == Slice("readrandomsmall")) {
  341. int n = reads_;
  342. reads_ /= 1000;
  343. ReadRandom();
  344. reads_ = n;
  345. } else if (name == Slice("compact")) {
  346. Compact();
  347. } else if (name == Slice("crc32c")) {
  348. Crc32c(4096, "(4K per op)");
  349. } else if (name == Slice("acquireload")) {
  350. AcquireLoad();
  351. } else if (name == Slice("snappycomp")) {
  352. SnappyCompress();
  353. } else if (name == Slice("snappyuncomp")) {
  354. SnappyUncompress();
  355. } else if (name == Slice("heapprofile")) {
  356. HeapProfile();
  357. } else if (name == Slice("stats")) {
  358. PrintStats();
  359. } else {
  360. known = false;
  361. if (name != Slice()) { // No error message for empty name
  362. fprintf(stderr, "unknown benchmark '%s'\n", name.ToString().c_str());
  363. }
  364. }
  365. if (known) {
  366. Stop(name);
  367. }
  368. }
  369. }
  370. private:
  371. void Crc32c(int size, const char* label) {
  372. // Checksum about 500MB of data total
  373. std::string data(size, 'x');
  374. int64_t bytes = 0;
  375. uint32_t crc = 0;
  376. while (bytes < 500 * 1048576) {
  377. crc = crc32c::Value(data.data(), size);
  378. FinishedSingleOp();
  379. bytes += size;
  380. }
  381. // Print so result is not dead
  382. fprintf(stderr, "... crc=0x%x\r", static_cast<unsigned int>(crc));
  383. bytes_ = bytes;
  384. message_ = label;
  385. }
  386. void AcquireLoad() {
  387. int dummy;
  388. port::AtomicPointer ap(&dummy);
  389. int count = 0;
  390. void *ptr = NULL;
  391. message_ = "(each op is 1000 loads)";
  392. while (count < 100000) {
  393. for (int i = 0; i < 1000; i++) {
  394. ptr = ap.Acquire_Load();
  395. }
  396. count++;
  397. FinishedSingleOp();
  398. }
  399. if (ptr == NULL) exit(1); // Disable unused variable warning.
  400. }
  401. void SnappyCompress() {
  402. Slice input = gen_.Generate(Options().block_size);
  403. int64_t bytes = 0;
  404. int64_t produced = 0;
  405. bool ok = true;
  406. std::string compressed;
  407. while (ok && bytes < 1024 * 1048576) { // Compress 1G
  408. ok = port::Snappy_Compress(input.data(), input.size(), &compressed);
  409. produced += compressed.size();
  410. bytes += input.size();
  411. FinishedSingleOp();
  412. }
  413. if (!ok) {
  414. message_ = "(snappy failure)";
  415. } else {
  416. char buf[100];
  417. snprintf(buf, sizeof(buf), "(output: %.1f%%)",
  418. (produced * 100.0) / bytes);
  419. message_ = buf;
  420. bytes_ = bytes;
  421. }
  422. }
  423. void SnappyUncompress() {
  424. Slice input = gen_.Generate(Options().block_size);
  425. std::string compressed;
  426. bool ok = port::Snappy_Compress(input.data(), input.size(), &compressed);
  427. int64_t bytes = 0;
  428. std::string uncompressed;
  429. while (ok && bytes < 1024 * 1048576) { // Compress 1G
  430. ok = port::Snappy_Uncompress(compressed.data(), compressed.size(),
  431. &uncompressed);
  432. bytes += uncompressed.size();
  433. FinishedSingleOp();
  434. }
  435. if (!ok) {
  436. message_ = "(snappy failure)";
  437. } else {
  438. bytes_ = bytes;
  439. }
  440. }
  441. void Open() {
  442. assert(db_ == NULL);
  443. Options options;
  444. options.create_if_missing = !FLAGS_use_existing_db;
  445. options.block_cache = cache_;
  446. options.write_buffer_size = FLAGS_write_buffer_size;
  447. Status s = DB::Open(options, FLAGS_db, &db_);
  448. if (!s.ok()) {
  449. fprintf(stderr, "open error: %s\n", s.ToString().c_str());
  450. exit(1);
  451. }
  452. }
  453. void Write(const WriteOptions& options, Order order, DBState state,
  454. int num_entries, int value_size, int entries_per_batch) {
  455. if (state == FRESH) {
  456. if (FLAGS_use_existing_db) {
  457. message_ = "skipping (--use_existing_db is true)";
  458. return;
  459. }
  460. delete db_;
  461. db_ = NULL;
  462. DestroyDB(FLAGS_db, Options());
  463. Open();
  464. Start(); // Do not count time taken to destroy/open
  465. }
  466. if (num_entries != num_) {
  467. char msg[100];
  468. snprintf(msg, sizeof(msg), "(%d ops)", num_entries);
  469. message_ = msg;
  470. }
  471. WriteBatch batch;
  472. Status s;
  473. std::string val;
  474. for (int i = 0; i < num_entries; i += entries_per_batch) {
  475. batch.Clear();
  476. for (int j = 0; j < entries_per_batch; j++) {
  477. const int k = (order == SEQUENTIAL) ? i+j : (rand_.Next() % FLAGS_num);
  478. char key[100];
  479. snprintf(key, sizeof(key), "%016d", k);
  480. batch.Put(key, gen_.Generate(value_size));
  481. bytes_ += value_size + strlen(key);
  482. FinishedSingleOp();
  483. }
  484. s = db_->Write(options, &batch);
  485. if (!s.ok()) {
  486. fprintf(stderr, "put error: %s\n", s.ToString().c_str());
  487. exit(1);
  488. }
  489. }
  490. }
  491. void ReadSequential() {
  492. Iterator* iter = db_->NewIterator(ReadOptions());
  493. int i = 0;
  494. for (iter->SeekToFirst(); i < reads_ && iter->Valid(); iter->Next()) {
  495. bytes_ += iter->key().size() + iter->value().size();
  496. FinishedSingleOp();
  497. ++i;
  498. }
  499. delete iter;
  500. }
  501. void ReadReverse() {
  502. Iterator* iter = db_->NewIterator(ReadOptions());
  503. int i = 0;
  504. for (iter->SeekToLast(); i < reads_ && iter->Valid(); iter->Prev()) {
  505. bytes_ += iter->key().size() + iter->value().size();
  506. FinishedSingleOp();
  507. ++i;
  508. }
  509. delete iter;
  510. }
  511. void ReadRandom() {
  512. ReadOptions options;
  513. std::string value;
  514. for (int i = 0; i < reads_; i++) {
  515. char key[100];
  516. const int k = rand_.Next() % FLAGS_num;
  517. snprintf(key, sizeof(key), "%016d", k);
  518. db_->Get(options, key, &value);
  519. FinishedSingleOp();
  520. }
  521. }
  522. void ReadHot() {
  523. ReadOptions options;
  524. std::string value;
  525. const int range = (FLAGS_num + 99) / 100;
  526. for (int i = 0; i < reads_; i++) {
  527. char key[100];
  528. const int k = rand_.Next() % range;
  529. snprintf(key, sizeof(key), "%016d", k);
  530. db_->Get(options, key, &value);
  531. FinishedSingleOp();
  532. }
  533. }
  534. void Compact() {
  535. DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);
  536. dbi->TEST_CompactMemTable();
  537. int max_level_with_files = 1;
  538. for (int level = 1; level < config::kNumLevels; level++) {
  539. std::string property;
  540. char name[100];
  541. snprintf(name, sizeof(name), "leveldb.num-files-at-level%d", level);
  542. if (db_->GetProperty(name, &property) && atoi(property.c_str()) > 0) {
  543. max_level_with_files = level;
  544. }
  545. }
  546. for (int level = 0; level < max_level_with_files; level++) {
  547. dbi->TEST_CompactRange(level, "", "~");
  548. }
  549. }
  550. void PrintStats() {
  551. std::string stats;
  552. if (!db_->GetProperty("leveldb.stats", &stats)) {
  553. message_ = "(failed)";
  554. } else {
  555. post_message_ = stats;
  556. }
  557. }
  558. static void WriteToFile(void* arg, const char* buf, int n) {
  559. reinterpret_cast<WritableFile*>(arg)->Append(Slice(buf, n));
  560. }
  561. void HeapProfile() {
  562. char fname[100];
  563. snprintf(fname, sizeof(fname), "%s/heap-%04d", FLAGS_db, ++heap_counter_);
  564. WritableFile* file;
  565. Status s = Env::Default()->NewWritableFile(fname, &file);
  566. if (!s.ok()) {
  567. message_ = s.ToString();
  568. return;
  569. }
  570. bool ok = port::GetHeapProfile(WriteToFile, file);
  571. delete file;
  572. if (!ok) {
  573. message_ = "not supported";
  574. Env::Default()->DeleteFile(fname);
  575. }
  576. }
  577. };
  578. }
  579. int main(int argc, char** argv) {
  580. FLAGS_write_buffer_size = leveldb::Options().write_buffer_size;
  581. FLAGS_open_files = leveldb::Options().max_open_files;
  582. for (int i = 1; i < argc; i++) {
  583. double d;
  584. int n;
  585. char junk;
  586. if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) {
  587. FLAGS_benchmarks = argv[i] + strlen("--benchmarks=");
  588. } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) {
  589. FLAGS_compression_ratio = d;
  590. } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 &&
  591. (n == 0 || n == 1)) {
  592. FLAGS_histogram = n;
  593. } else if (sscanf(argv[i], "--use_existing_db=%d%c", &n, &junk) == 1 &&
  594. (n == 0 || n == 1)) {
  595. FLAGS_use_existing_db = n;
  596. } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) {
  597. FLAGS_num = n;
  598. } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) {
  599. FLAGS_reads = n;
  600. } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) {
  601. FLAGS_value_size = n;
  602. } else if (sscanf(argv[i], "--write_buffer_size=%d%c", &n, &junk) == 1) {
  603. FLAGS_write_buffer_size = n;
  604. } else if (sscanf(argv[i], "--cache_size=%d%c", &n, &junk) == 1) {
  605. FLAGS_cache_size = n;
  606. } else if (sscanf(argv[i], "--open_files=%d%c", &n, &junk) == 1) {
  607. FLAGS_open_files = n;
  608. } else if (strncmp(argv[i], "--db=", 5) == 0) {
  609. FLAGS_db = argv[i] + 5;
  610. } else {
  611. fprintf(stderr, "Invalid flag '%s'\n", argv[i]);
  612. exit(1);
  613. }
  614. }
  615. leveldb::Benchmark benchmark;
  616. benchmark.Run();
  617. return 0;
  618. }