Repository: parquet-cpp Updated Branches: refs/heads/master 83469301a -> a236916e5
PARQUET-600: Add benchmarks for RLE-Level encoding Author: Uwe L. Korn <[email protected]> Closes #95 from xhochy/parquet-600 and squashes the following commits: 87882fd [Uwe L. Korn] Use MaxBufferSize for size estimation 0fd2a34 [Uwe L. Korn] PARQUET-600: Add benchmarks for RLE-Level encoding Project: http://git-wip-us.apache.org/repos/asf/parquet-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/parquet-cpp/commit/a236916e Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/a236916e Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/a236916e Branch: refs/heads/master Commit: a236916e5226ce92b638b2d1703f4598c92bd708 Parents: 8346930 Author: Uwe L. Korn <[email protected]> Authored: Mon May 16 23:27:39 2016 -0700 Committer: Wes McKinney <[email protected]> Committed: Mon May 16 23:27:39 2016 -0700 ---------------------------------------------------------------------- src/parquet/column/CMakeLists.txt | 1 + src/parquet/column/level-benchmark.cc | 69 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/a236916e/src/parquet/column/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/parquet/column/CMakeLists.txt b/src/parquet/column/CMakeLists.txt index d64be6c..344795c 100644 --- a/src/parquet/column/CMakeLists.txt +++ b/src/parquet/column/CMakeLists.txt @@ -32,3 +32,4 @@ ADD_PARQUET_TEST(properties-test) ADD_PARQUET_TEST(scanner-test) ADD_PARQUET_BENCHMARK(column-io-benchmark) +ADD_PARQUET_BENCHMARK(level-benchmark) http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/a236916e/src/parquet/column/level-benchmark.cc ---------------------------------------------------------------------- diff --git a/src/parquet/column/level-benchmark.cc b/src/parquet/column/level-benchmark.cc new file mode 100644 index 0000000..fbb3181 --- /dev/null +++ b/src/parquet/column/level-benchmark.cc @@ -0,0 +1,69 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "benchmark/benchmark.h" + +#include "parquet/column/levels.h" +#include "parquet/util/buffer.h" + +namespace parquet { + +namespace benchmark { + +static void BM_RleEncoding(::benchmark::State& state) { + // TODO: More than just all 0s + std::vector<int16_t> levels(state.range_x(), 0); + int16_t max_level = 1; + int64_t rle_size = LevelEncoder::MaxBufferSize(Encoding::RLE, max_level, levels.size()); + auto buffer_rle = std::make_shared<OwnedMutableBuffer>(rle_size); + + while (state.KeepRunning()) { + LevelEncoder level_encoder; + level_encoder.Init(Encoding::RLE, max_level, levels.size(), + buffer_rle->mutable_data(), buffer_rle->size()); + level_encoder.Encode(levels.size(), levels.data()); + } + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(int16_t)); +} + +BENCHMARK(BM_RleEncoding)->Range(1024, 65536); + +static void BM_RleDecoding(::benchmark::State& state) { + LevelEncoder level_encoder; + // TODO: More than just all 0s + std::vector<int16_t> levels(state.range_x(), 0); + int16_t max_level = 1; + int64_t rle_size = LevelEncoder::MaxBufferSize(Encoding::RLE, max_level, levels.size()); + auto buffer_rle = std::make_shared<OwnedMutableBuffer>(rle_size); + level_encoder.Init(Encoding::RLE, max_level, levels.size(), buffer_rle->mutable_data(), + buffer_rle->size()); + level_encoder.Encode(levels.size(), levels.data()); + + while (state.KeepRunning()) { + LevelDecoder level_decoder; + level_decoder.SetData(Encoding::RLE, max_level, levels.size(), buffer_rle->data()); + level_decoder.Decode(state.range_x(), levels.data()); + } + + state.SetBytesProcessed(state.iterations() * state.range_x() * sizeof(int16_t)); +} + +BENCHMARK(BM_RleDecoding)->Range(1024, 65536); + +} // namespace benchmark + +} // namespace parquet
