Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed May 11, 2024
1 parent 7d3508e commit bfd4ca2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions velox/functions/sparksql/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ target_link_libraries(
add_executable(velox_sparksql_benchmarks_compare CompareBenchmark.cpp)
target_link_libraries(velox_sparksql_benchmarks_compare velox_functions_spark
velox_benchmark_builder velox_vector_test_lib)

add_executable(velox_sparksql_benchmarks_hash HashBenchmark.cpp)
target_link_libraries(velox_sparksql_benchmarks_hash velox_functions_spark
velox_benchmark_builder velox_vector_test_lib)
1 change: 1 addition & 0 deletions velox/functions/sparksql/benchmarks/CompareBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using namespace facebook::velox;

int main(int argc, char** argv) {
folly::Init init(&argc, &argv);
memory::MemoryManager::initialize({});
functions::sparksql::registerFunctions("");

ExpressionBenchmarkBuilder benchmarkBuilder;
Expand Down
53 changes: 53 additions & 0 deletions velox/functions/sparksql/benchmarks/HashBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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 <folly/Benchmark.h>
#include <folly/init/Init.h>

#include "velox/benchmarks/ExpressionBenchmarkBuilder.h"
#include "velox/functions/sparksql/Register.h"

using namespace facebook;

using namespace facebook::velox;

int main(int argc, char** argv) {
folly::Init init(&argc, &argv);
memory::MemoryManager::initialize({});
functions::sparksql::registerFunctions("");

ExpressionBenchmarkBuilder benchmarkBuilder;

std::vector<TypePtr> inputTypes = {
ARRAY(MAP(INTEGER(), VARCHAR())),
ROW({"f_map", "f_array"}, {MAP(INTEGER(), VARCHAR()), ARRAY(INTEGER())}),
};

for (auto& inputType : inputTypes) {
benchmarkBuilder
.addBenchmarkSet(
fmt::format("hash_{}", inputType->toString()),
ROW({"c0"}, {inputType}))
.withFuzzerOptions({.vectorSize = 1000, .nullRatio = 0.1})
.addExpression("hash", "hash(c0)")
.addExpression("xxhash64", "xxhash64(c0)")
.withIterations(100);
}

benchmarkBuilder.registerBenchmarks();
folly::runBenchmarks();
return 0;
}

0 comments on commit bfd4ca2

Please sign in to comment.