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

Method SnappyCompress

src/leveldb/benchmarks/db_bench.cc:633–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631 }
632
633 void SnappyCompress(ThreadState* thread) {
634 RandomGenerator gen;
635 Slice input = gen.Generate(Options().block_size);
636 int64_t bytes = 0;
637 int64_t produced = 0;
638 bool ok = true;
639 std::string compressed;
640 while (ok && bytes < 1024 * 1048576) { // Compress 1G
641 ok = port::Snappy_Compress(input.data(), input.size(), &compressed);
642 produced += compressed.size();
643 bytes += input.size();
644 thread->stats.FinishedSingleOp();
645 }
646
647 if (!ok) {
648 thread->stats.AddMessage("(snappy failure)");
649 } else {
650 char buf[100];
651 snprintf(buf, sizeof(buf), "(output: %.1f%%)",
652 (produced * 100.0) / bytes);
653 thread->stats.AddMessage(buf);
654 thread->stats.AddBytes(bytes);
655 }
656 }
657
658 void SnappyUncompress(ThreadState* thread) {
659 RandomGenerator gen;

Callers

nothing calls this directly

Calls 8

Snappy_CompressFunction · 0.85
AddMessageMethod · 0.80
AddBytesMethod · 0.80
OptionsClass · 0.50
GenerateMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
FinishedSingleOpMethod · 0.45

Tested by

no test coverage detected