Skip to content

Commit b45e7ea

Browse files
committed
build: add benchmark build scaffolding
1 parent f4f6359 commit b45e7ea

9 files changed

Lines changed: 160 additions & 0 deletions

File tree

.github/workflows/cpp-linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
7878
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
7979
-DICEBERG_BUILD_SQL_CATALOG=ON \
80+
-DICEBERG_BUILD_BENCHMARKS=ON \
8081
-DICEBERG_SQL_SQLITE=ON \
8182
-DICEBERG_SQL_POSTGRESQL=ON \
8283
-DICEBERG_SQL_MYSQL=ON

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4040
option(ICEBERG_BUILD_STATIC "Build static library" ON)
4141
option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
4242
option(ICEBERG_BUILD_TESTS "Build tests" ON)
43+
option(ICEBERG_BUILD_BENCHMARKS "Build benchmarks" OFF)
4344
option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
4445
option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
4546
option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration tests" OFF)

meson.options

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ option(
5252
)
5353

5454
option('tests', type: 'feature', description: 'Build tests', value: 'enabled')
55+
56+
option(
57+
'benchmarks',
58+
type: 'feature',
59+
description: 'Build benchmarks',
60+
value: 'disabled',
61+
)

src/iceberg/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,7 @@ endif()
361361
if(ICEBERG_BUILD_TESTS)
362362
add_subdirectory(test)
363363
endif()
364+
365+
if(ICEBERG_BUILD_BENCHMARKS)
366+
add_subdirectory(benchmark)
367+
endif()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
set(BENCHMARK_ENABLE_GTEST_TESTS
19+
OFF
20+
CACHE BOOL "" FORCE)
21+
set(BENCHMARK_ENABLE_INSTALL
22+
OFF
23+
CACHE BOOL "" FORCE)
24+
set(BENCHMARK_ENABLE_TESTING
25+
OFF
26+
CACHE BOOL "" FORCE)
27+
28+
fetchcontent_declare(google_benchmark
29+
GIT_REPOSITORY https://github.com/google/benchmark.git
30+
GIT_TAG a4cf155615c63e019ae549e31703bf367df5b471 # v1.8.4
31+
FIND_PACKAGE_ARGS
32+
NAMES
33+
benchmark
34+
CONFIG)
35+
fetchcontent_makeavailable(google_benchmark)
36+
37+
add_executable(metrics_evaluator_benchmark metrics_evaluator_benchmark.cc)
38+
target_link_libraries(metrics_evaluator_benchmark
39+
PRIVATE "$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
40+
"$<IF:$<TARGET_EXISTS:benchmark::benchmark>,benchmark::benchmark,benchmark>"
41+
)

src/iceberg/benchmark/meson.build

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
benchmark_dep = dependency('benchmark', required: true)
19+
20+
metrics_evaluator_benchmark = executable(
21+
'metrics_evaluator_benchmark',
22+
sources: files('metrics_evaluator_benchmark.cc'),
23+
dependencies: [iceberg_dep, benchmark_dep],
24+
)
25+
26+
benchmark('metrics_evaluator_benchmark', metrics_evaluator_benchmark)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include <benchmark/benchmark.h>
21+
22+
namespace iceberg {
23+
namespace {
24+
25+
void BM_BenchmarkSmoke(benchmark::State& state) {
26+
while (state.KeepRunning()) {
27+
benchmark::DoNotOptimize(state.iterations());
28+
}
29+
30+
state.SetItemsProcessed(state.iterations());
31+
}
32+
33+
BENCHMARK(BM_BenchmarkSmoke);
34+
35+
} // namespace
36+
} // namespace iceberg
37+
38+
int main(int argc, char** argv) {
39+
benchmark::Initialize(&argc, argv);
40+
if (benchmark::ReportUnrecognizedArguments(argc, argv)) {
41+
return 1;
42+
}
43+
benchmark::RunSpecifiedBenchmarks();
44+
benchmark::Shutdown();
45+
return 0;
46+
}

src/iceberg/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,7 @@ subdir('inspect')
319319
if get_option('tests').enabled()
320320
subdir('test')
321321
endif
322+
323+
if get_option('benchmarks').enabled()
324+
subdir('benchmark')
325+
endif

subprojects/google-benchmark.wrap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[wrap-file]
19+
directory = benchmark-1.8.4
20+
source_url = https://github.com/google/benchmark/archive/refs/tags/v1.8.4.tar.gz
21+
source_filename = benchmark-1.8.4.tar.gz
22+
source_hash = 3e7059b6b11fb1bbe28e33e02519398ca94c1818874ebed18e504dc6f709be45
23+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/google-benchmark_1.8.4-5/benchmark-1.8.4.tar.gz
24+
patch_filename = google-benchmark_1.8.4-5_patch.zip
25+
patch_url = https://wrapdb.mesonbuild.com/v2/google-benchmark_1.8.4-5/get_patch
26+
patch_hash = 671ffed65f1e95e8c20edb7a06eb54476797e58169160b255f52dc71f4b83957
27+
wrapdb_version = 1.8.4-5
28+
29+
[provide]
30+
dependency_names = benchmark, benchmark_main

0 commit comments

Comments
 (0)