db_bench: in uncompress benchmark, get Snappy size from compressed stream

Summary: Now in benchmark "uncompress" in db_bench, we get size from compressed stream for all other compression types except Snappy, where we allocate memory based on parameter. Change it to match to behavior of other compression types.

Test Plan: Run ./db_bench --benchmarks=uncompress with snappy and other compression types.

Reviewers: yhchiang, kradhakrishnan, anthony, IslamAbdelRahman, igor

Reviewed By: igor

Subscribers: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D51681
main
sdong 9 years ago
parent 9c227923c6
commit ac8e56f050
  1. 19
      db/db_bench.cc

@ -2267,12 +2267,19 @@ class Benchmark {
while (ok && bytes < 1024 * 1048576) { while (ok && bytes < 1024 * 1048576) {
char *uncompressed = nullptr; char *uncompressed = nullptr;
switch (FLAGS_compression_type_e) { switch (FLAGS_compression_type_e) {
case rocksdb::kSnappyCompression: case rocksdb::kSnappyCompression: {
// allocate here to make comparison fair // get size and allocate here to make comparison fair
uncompressed = new char[input.size()]; size_t ulength = 0;
ok = Snappy_Uncompress(compressed.data(), compressed.size(), if (!Snappy_GetUncompressedLength(compressed.data(),
uncompressed); compressed.size(), &ulength)) {
break; ok = false;
break;
}
uncompressed = new char[ulength];
ok = Snappy_Uncompress(compressed.data(), compressed.size(),
uncompressed);
break;
}
case rocksdb::kZlibCompression: case rocksdb::kZlibCompression:
uncompressed = Zlib_Uncompress(compressed.data(), compressed.size(), uncompressed = Zlib_Uncompress(compressed.data(), compressed.size(),
&decompress_size, 2); &decompress_size, 2);

Loading…
Cancel
Save