From ed4bf85d8d7a92d93b026267a8e26b73254d207e Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 3 May 2016 17:41:34 -0700 Subject: [PATCH] PARQUET-597: Add data rates to benchmark output Author: Uwe L. Korn Closes #94 from xhochy/parquet-597 and squashes the following commits: 6442eb7 [Uwe L. Korn] PARQUET-597: Add data rates to benchmark output Change-Id: Ifce2d31441e7694e4b68ec0c4f41be895f802e46 --- cpp/src/parquet/column/column-io-benchmark.cc | 13 +++++++++++++ cpp/src/parquet/encodings/encoding-benchmark.cc | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/cpp/src/parquet/column/column-io-benchmark.cc b/cpp/src/parquet/column/column-io-benchmark.cc index 8007ed5573380..3bc258219a47f 100644 --- a/cpp/src/parquet/column/column-io-benchmark.cc +++ b/cpp/src/parquet/column/column-io-benchmark.cc @@ -44,6 +44,17 @@ std::shared_ptr Int64Schema(Repetition::type repetition) { node, repetition != Repetition::REQUIRED, repetition == Repetition::REPEATED); } +void SetBytesProcessed(::benchmark::State& state, Repetition::type repetition) { + int64_t bytes_processed = state.iterations() * state.range_x() * sizeof(int64_t); + if (repetition != Repetition::REQUIRED) { + bytes_processed += state.iterations() * state.range_x() * sizeof(int16_t); + } + if (repetition == Repetition::REPEATED) { + bytes_processed += state.iterations() * state.range_x() * sizeof(int16_t); + } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(int16_t)); +} + template static void BM_WriteInt64Column(::benchmark::State& state) { format::ColumnChunk metadata; @@ -60,6 +71,7 @@ static void BM_WriteInt64Column(::benchmark::State& state) { values.size(), definition_levels.data(), repetition_levels.data(), values.data()); writer->Close(); } + SetBytesProcessed(state, repetition); } BENCHMARK_TEMPLATE(BM_WriteInt64Column, Repetition::REQUIRED)->Range(1024, 65536); @@ -103,6 +115,7 @@ static void BM_ReadInt64Column(::benchmark::State& state) { repetition_levels_out.data(), values_out.data(), &values_read); } } + SetBytesProcessed(state, repetition); } BENCHMARK_TEMPLATE(BM_ReadInt64Column, Repetition::REQUIRED) diff --git a/cpp/src/parquet/encodings/encoding-benchmark.cc b/cpp/src/parquet/encodings/encoding-benchmark.cc index 92bc29e672dca..f9265bd407afb 100644 --- a/cpp/src/parquet/encodings/encoding-benchmark.cc +++ b/cpp/src/parquet/encodings/encoding-benchmark.cc @@ -31,6 +31,7 @@ static void BM_PlainEncodingBoolean(::benchmark::State& state) { InMemoryOutputStream dst; encoder.Encode(values, values.size(), &dst); } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(bool)); } BENCHMARK(BM_PlainEncodingBoolean)->Range(1024, 65536); @@ -49,6 +50,7 @@ static void BM_PlainDecodingBoolean(::benchmark::State& state) { decoder.Decode(output, values.size()); } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(bool)); delete[] output; } @@ -62,6 +64,7 @@ static void BM_PlainEncodingInt64(::benchmark::State& state) { InMemoryOutputStream dst; encoder.Encode(values.data(), values.size(), &dst); } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(int64_t)); } BENCHMARK(BM_PlainEncodingInt64)->Range(1024, 65536); @@ -78,6 +81,7 @@ static void BM_PlainDecodingInt64(::benchmark::State& state) { decoder.SetData(values.size(), buf->data(), buf->size()); decoder.Decode(values.data(), values.size()); } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(int64_t)); } BENCHMARK(BM_PlainDecodingInt64)->Range(1024, 65536);