diff --git a/snappy-test.h b/snappy-test.h index e31a78d..61e19f3 100644 --- a/snappy-test.h +++ b/snappy-test.h @@ -265,6 +265,8 @@ extern Benchmark* Benchmark_BM_UFlat; extern Benchmark* Benchmark_BM_UIOVec; extern Benchmark* Benchmark_BM_UValidate; extern Benchmark* Benchmark_BM_ZFlat; +extern Benchmark* Benchmark_BM_ZFlatAll; +extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize; void ResetBenchmarkTiming(); void StartBenchmarkTiming(); @@ -416,6 +418,8 @@ static inline void RunSpecifiedBenchmarks() { snappy::Benchmark_BM_UIOVec->Run(); snappy::Benchmark_BM_UValidate->Run(); snappy::Benchmark_BM_ZFlat->Run(); + snappy::Benchmark_BM_ZFlatAll->Run(); + snappy::Benchmark_BM_ZFlatIncreasingTableSize->Run(); fprintf(stderr, "\n"); } diff --git a/snappy_unittest.cc b/snappy_unittest.cc index 40a0a9f..eb9594a 100644 --- a/snappy_unittest.cc +++ b/snappy_unittest.cc @@ -1410,19 +1410,23 @@ static void BM_ZFlat(int iters, int arg) { } BENCHMARK(BM_ZFlat)->DenseRange(0, ARRAYSIZE(files) - 1); -static void BM_ZFlatAll(int iters) { +static void BM_ZFlatAll(int iters, int arg) { StopBenchmarkTiming(); + CHECK_EQ(arg, 0); const int num_files = ARRAYSIZE(files); std::vector contents(num_files); std::vector dst(num_files); + int64 total_contents_size = 0; for (int i = 0; i < num_files; ++i) { contents[i] = ReadTestDataFile(files[i].filename, files[i].size_limit); dst[i] = new char[snappy::MaxCompressedLength(contents[i].size())]; + total_contents_size += contents[i].size(); } + SetBenchmarkBytesProcessed(static_cast(iters) * total_contents_size); StartBenchmarkTiming(); size_t zsize = 0; @@ -1437,27 +1441,32 @@ static void BM_ZFlatAll(int iters) { for (int i = 0; i < num_files; ++i) { delete[] dst[i]; } + SetBenchmarkLabel(StringPrintf("%d files", num_files)); } -BENCHMARK(BM_ZFlatAll); +BENCHMARK(BM_ZFlatAll)->DenseRange(0, 0); -static void BM_ZFlatIncreasingTableSize(int iters) { +static void BM_ZFlatIncreasingTableSize(int iters, int arg) { StopBenchmarkTiming(); - QCHECK_GT(ARRAYSIZE(files), 0); + CHECK_EQ(arg, 0); + CHECK_GT(ARRAYSIZE(files), 0); const std::string base_content = ReadTestDataFile(files[0].filename, files[0].size_limit); std::vector contents; std::vector dst; + int64 total_contents_size = 0; for (int table_bits = kMinHashTableBits; table_bits <= kMaxHashTableBits; ++table_bits) { std::string content = base_content; content.resize(1 << table_bits); dst.push_back(new char[snappy::MaxCompressedLength(content.size())]); + total_contents_size += content.size(); contents.push_back(std::move(content)); } size_t zsize = 0; + SetBenchmarkBytesProcessed(static_cast(iters) * total_contents_size); StartBenchmarkTiming(); while (iters-- > 0) { for (int i = 0; i < contents.size(); ++i) {