Skip to content

Commit aac110d

Browse files
authored
GH-45792: [C++] Add benchmarks to Meson configuration (#45793)
### Rationale for this change This makes it possible to add benchmarks to the Meson configuration ### What changes are included in this PR? Benchmarks from the top level configuration are added ### Are these changes tested? Locally yes. To do so, simply: ```sh meson setup builddir -Dbenchmarks=true meson test -C builddir --benchmark ``` ### Are there any user-facing changes? No * GitHub Issue: #45792 Authored-by: Will Ayd <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent b957769 commit aac110d

File tree

4 files changed

+78
-8
lines changed

4 files changed

+78
-8
lines changed

cpp/meson.build

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ if git_description == ''
5656
git_description = run_command('git', 'describe', '--tags', check: false).stdout().strip()
5757
endif
5858

59+
needs_benchmarks = get_option('benchmarks')
5960
needs_filesystem = false
6061
needs_integration = false
6162
needs_tests = get_option('tests')
62-
needs_ipc = get_option('ipc') or needs_tests
63-
needs_testing = get_option('testing') or needs_tests
63+
needs_ipc = get_option('ipc') or needs_tests or needs_benchmarks
64+
needs_testing = get_option('testing') or needs_tests or needs_benchmarks
6465
needs_json = get_option('json') or needs_testing
6566

6667
subdir('src/arrow')

cpp/meson.options

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
option(
19+
'benchmarks',
20+
type: 'boolean',
21+
description: 'Build the Arrow micro benchmarks',
22+
value: false,
23+
)
24+
1825
option(
1926
'ipc',
2027
type: 'boolean',

cpp/src/arrow/meson.build

+37-6
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ install_headers(
355355
install_dir: 'arrow',
356356
)
357357

358-
if needs_tests
358+
if needs_testing
359359
filesystem_dep = dependency(
360360
'boost',
361361
modules: ['filesystem'],
@@ -440,13 +440,44 @@ if needs_ipc
440440
}
441441
endif
442442

443-
foreach key, val : arrow_tests
443+
if needs_tests
444+
foreach key, val : arrow_tests
445+
exc = executable(
446+
key,
447+
sources: val['sources'],
448+
dependencies: [arrow_test_dep, val.get('dependencies', [])],
449+
)
450+
test(key, exc)
451+
endforeach
452+
endif
453+
454+
if needs_benchmarks
455+
benchmark_dep = dependency(
456+
'benchmark',
457+
default_options: {'tests': 'disabled'},
458+
)
459+
else
460+
benchmark_dep = disabler()
461+
endif
462+
463+
arrow_benchmarks = [
464+
'builder_benchmark',
465+
'chunk_resolver_benchmark',
466+
'compare_benchmark',
467+
'memory_pool_benchmark',
468+
'type_benchmark',
469+
'tensor_benchmark',
470+
]
471+
472+
foreach benchmark : arrow_benchmarks
473+
benchmark_name = 'arrow-@0@'.format(benchmark.replace('_', '-'))
444474
exc = executable(
445-
key,
446-
sources: val['sources'],
447-
dependencies: [arrow_test_dep, val.get('dependencies', [])],
475+
benchmark_name,
476+
sources: '@[email protected]'.format(benchmark),
477+
dependencies: [arrow_test_dep, benchmark_dep],
448478
)
449-
test(key, exc)
479+
480+
benchmark(benchmark_name, exc)
450481
endforeach
451482

452483
version = meson.project_version()

cpp/subprojects/google-benchmark.wrap

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
patch_filename = google-benchmark_1.8.4-1_patch.zip
24+
patch_url = https://wrapdb.mesonbuild.com/v2/google-benchmark_1.8.4-1/get_patch
25+
patch_hash = 77cdae534fe12b6783c1267de3673d3462b229054519034710d581b419e73cca
26+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/google-benchmark_1.8.4-1/benchmark-1.8.4.tar.gz
27+
wrapdb_version = 1.8.4-1
28+
29+
[provide]
30+
benchmark = google_benchmark_dep
31+
benchmark-main = google_benchmark_main_dep

0 commit comments

Comments
 (0)