MCPcopy Create free account
hub / github.com/ElementsProject/elements / DoWrite

Method DoWrite

src/leveldb/benchmarks/db_bench.cc:711–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709 void WriteRandom(ThreadState* thread) { DoWrite(thread, false); }
710
711 void DoWrite(ThreadState* thread, bool seq) {
712 if (num_ != FLAGS_num) {
713 char msg[100];
714 snprintf(msg, sizeof(msg), "(%d ops)", num_);
715 thread->stats.AddMessage(msg);
716 }
717
718 RandomGenerator gen;
719 WriteBatch batch;
720 Status s;
721 int64_t bytes = 0;
722 for (int i = 0; i < num_; i += entries_per_batch_) {
723 batch.Clear();
724 for (int j = 0; j < entries_per_batch_; j++) {
725 const int k = seq ? i + j : (thread->rand.Next() % FLAGS_num);
726 char key[100];
727 snprintf(key, sizeof(key), "%016d", k);
728 batch.Put(key, gen.Generate(value_size_));
729 bytes += value_size_ + strlen(key);
730 thread->stats.FinishedSingleOp();
731 }
732 s = db_->Write(write_options_, &batch);
733 if (!s.ok()) {
734 fprintf(stderr, "put error: %s\n", s.ToString().c_str());
735 exit(1);
736 }
737 }
738 thread->stats.AddBytes(bytes);
739 }
740
741 void ReadSequential(ThreadState* thread) {
742 Iterator* iter = db_->NewIterator(ReadOptions());

Callers

nothing calls this directly

Calls 9

AddMessageMethod · 0.80
AddBytesMethod · 0.80
ClearMethod · 0.45
NextMethod · 0.45
PutMethod · 0.45
GenerateMethod · 0.45
FinishedSingleOpMethod · 0.45
WriteMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected