Fix benchmarks.
PiperOrigin-RevId: 264420835
This commit is contained in:
committed by
Victor Costan
parent
6219c7787b
commit
c6bf1170d8
@@ -265,6 +265,8 @@ extern Benchmark* Benchmark_BM_UFlat;
|
|||||||
extern Benchmark* Benchmark_BM_UIOVec;
|
extern Benchmark* Benchmark_BM_UIOVec;
|
||||||
extern Benchmark* Benchmark_BM_UValidate;
|
extern Benchmark* Benchmark_BM_UValidate;
|
||||||
extern Benchmark* Benchmark_BM_ZFlat;
|
extern Benchmark* Benchmark_BM_ZFlat;
|
||||||
|
extern Benchmark* Benchmark_BM_ZFlatAll;
|
||||||
|
extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize;
|
||||||
|
|
||||||
void ResetBenchmarkTiming();
|
void ResetBenchmarkTiming();
|
||||||
void StartBenchmarkTiming();
|
void StartBenchmarkTiming();
|
||||||
@@ -416,6 +418,8 @@ static inline void RunSpecifiedBenchmarks() {
|
|||||||
snappy::Benchmark_BM_UIOVec->Run();
|
snappy::Benchmark_BM_UIOVec->Run();
|
||||||
snappy::Benchmark_BM_UValidate->Run();
|
snappy::Benchmark_BM_UValidate->Run();
|
||||||
snappy::Benchmark_BM_ZFlat->Run();
|
snappy::Benchmark_BM_ZFlat->Run();
|
||||||
|
snappy::Benchmark_BM_ZFlatAll->Run();
|
||||||
|
snappy::Benchmark_BM_ZFlatIncreasingTableSize->Run();
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1410,19 +1410,23 @@ static void BM_ZFlat(int iters, int arg) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BM_ZFlat)->DenseRange(0, ARRAYSIZE(files) - 1);
|
BENCHMARK(BM_ZFlat)->DenseRange(0, ARRAYSIZE(files) - 1);
|
||||||
|
|
||||||
static void BM_ZFlatAll(int iters) {
|
static void BM_ZFlatAll(int iters, int arg) {
|
||||||
StopBenchmarkTiming();
|
StopBenchmarkTiming();
|
||||||
|
|
||||||
|
CHECK_EQ(arg, 0);
|
||||||
const int num_files = ARRAYSIZE(files);
|
const int num_files = ARRAYSIZE(files);
|
||||||
|
|
||||||
std::vector<std::string> contents(num_files);
|
std::vector<std::string> contents(num_files);
|
||||||
std::vector<char*> dst(num_files);
|
std::vector<char*> dst(num_files);
|
||||||
|
|
||||||
|
int64 total_contents_size = 0;
|
||||||
for (int i = 0; i < num_files; ++i) {
|
for (int i = 0; i < num_files; ++i) {
|
||||||
contents[i] = ReadTestDataFile(files[i].filename, files[i].size_limit);
|
contents[i] = ReadTestDataFile(files[i].filename, files[i].size_limit);
|
||||||
dst[i] = new char[snappy::MaxCompressedLength(contents[i].size())];
|
dst[i] = new char[snappy::MaxCompressedLength(contents[i].size())];
|
||||||
|
total_contents_size += contents[i].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetBenchmarkBytesProcessed(static_cast<int64>(iters) * total_contents_size);
|
||||||
StartBenchmarkTiming();
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
size_t zsize = 0;
|
size_t zsize = 0;
|
||||||
@@ -1437,27 +1441,32 @@ static void BM_ZFlatAll(int iters) {
|
|||||||
for (int i = 0; i < num_files; ++i) {
|
for (int i = 0; i < num_files; ++i) {
|
||||||
delete[] dst[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();
|
StopBenchmarkTiming();
|
||||||
|
|
||||||
QCHECK_GT(ARRAYSIZE(files), 0);
|
CHECK_EQ(arg, 0);
|
||||||
|
CHECK_GT(ARRAYSIZE(files), 0);
|
||||||
const std::string base_content =
|
const std::string base_content =
|
||||||
ReadTestDataFile(files[0].filename, files[0].size_limit);
|
ReadTestDataFile(files[0].filename, files[0].size_limit);
|
||||||
|
|
||||||
std::vector<std::string> contents;
|
std::vector<std::string> contents;
|
||||||
std::vector<char*> dst;
|
std::vector<char*> dst;
|
||||||
|
int64 total_contents_size = 0;
|
||||||
for (int table_bits = kMinHashTableBits; table_bits <= kMaxHashTableBits;
|
for (int table_bits = kMinHashTableBits; table_bits <= kMaxHashTableBits;
|
||||||
++table_bits) {
|
++table_bits) {
|
||||||
std::string content = base_content;
|
std::string content = base_content;
|
||||||
content.resize(1 << table_bits);
|
content.resize(1 << table_bits);
|
||||||
dst.push_back(new char[snappy::MaxCompressedLength(content.size())]);
|
dst.push_back(new char[snappy::MaxCompressedLength(content.size())]);
|
||||||
|
total_contents_size += content.size();
|
||||||
contents.push_back(std::move(content));
|
contents.push_back(std::move(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t zsize = 0;
|
size_t zsize = 0;
|
||||||
|
SetBenchmarkBytesProcessed(static_cast<int64>(iters) * total_contents_size);
|
||||||
StartBenchmarkTiming();
|
StartBenchmarkTiming();
|
||||||
while (iters-- > 0) {
|
while (iters-- > 0) {
|
||||||
for (int i = 0; i < contents.size(); ++i) {
|
for (int i = 0; i < contents.size(); ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user