Skip to content

Commit 1ee894a

Browse files
pks-tgitster
authored andcommitted
meson: wire up benchmarks
Wire up benchmarks in Meson. The setup is mostly the same as how we wire up our tests. The only difference is that benchmarks get wired up via the `benchmark()` option instead of via `test()`, which gives them a bit of special treatment: - Benchmarks never run in parallel. - Benchmarks aren't run by default when tests are executed. - Meson does not inject the `MALLOC_PERTURB` environment variable. Using benchmarks is quite simple: ``` $ meson setup build # Run all benchmarks. $ meson test -C build --benchmark # Run a specific benchmark. $ meson test -C build --benchmark p0000-* ``` Other than that the usual command line arguments accepted when running tests are also accepted when running benchmarks. Note that the benchmarking target is somewhat limited because it will only run benchmarks for the current build. Other use cases, like running benchmarks against multiple different versions of Git, are not currently supported. Users should continue to use "t/perf/run" for those use cases. The script should get extended at one point in time to support Meson, but this is outside of the scope of this series. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58feccd commit 1ee894a

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
# # Execute single test interactively such that features like `debug ()` work.
7171
# $ meson test -i --test-args='-ix' t1400-update-ref
7272
#
73+
# # Execute all benchmarks.
74+
# $ meson test -i --benchmark
75+
#
76+
# # Execute single benchmark.
77+
# $ meson test -i --benchmark p0000-*
78+
#
7379
# Test execution is parallelized by default and scales with the number of
7480
# processor cores available. You can change the number of processes by passing
7581
# the `-jN` flag to `meson test`.
@@ -204,6 +210,7 @@ git = find_program('git', dirs: program_path, required: false)
204210
sed = find_program('sed', dirs: program_path)
205211
shell = find_program('sh', dirs: program_path)
206212
tar = find_program('tar', dirs: program_path)
213+
time = find_program('time', dirs: program_path, required: false)
207214

208215
# Sanity-check that programs required for the build exist.
209216
foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']

t/meson.build

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,71 @@ integration_tests = [
10961096
't9903-bash-prompt.sh',
10971097
]
10981098

1099+
benchmarks = [
1100+
'perf/p0000-perf-lib-sanity.sh',
1101+
'perf/p0001-rev-list.sh',
1102+
'perf/p0002-read-cache.sh',
1103+
'perf/p0003-delta-base-cache.sh',
1104+
'perf/p0004-lazy-init-name-hash.sh',
1105+
'perf/p0005-status.sh',
1106+
'perf/p0006-read-tree-checkout.sh',
1107+
'perf/p0007-write-cache.sh',
1108+
'perf/p0008-odb-fsync.sh',
1109+
'perf/p0071-sort.sh',
1110+
'perf/p0090-cache-tree.sh',
1111+
'perf/p0100-globbing.sh',
1112+
'perf/p1006-cat-file.sh',
1113+
'perf/p1400-update-ref.sh',
1114+
'perf/p1450-fsck.sh',
1115+
'perf/p1451-fsck-skip-list.sh',
1116+
'perf/p1500-graph-walks.sh',
1117+
'perf/p2000-sparse-operations.sh',
1118+
'perf/p3400-rebase.sh',
1119+
'perf/p3404-rebase-interactive.sh',
1120+
'perf/p4000-diff-algorithms.sh',
1121+
'perf/p4001-diff-no-index.sh',
1122+
'perf/p4002-diff-color-moved.sh',
1123+
'perf/p4205-log-pretty-formats.sh',
1124+
'perf/p4209-pickaxe.sh',
1125+
'perf/p4211-line-log.sh',
1126+
'perf/p4220-log-grep-engines.sh',
1127+
'perf/p4221-log-grep-engines-fixed.sh',
1128+
'perf/p5302-pack-index.sh',
1129+
'perf/p5303-many-packs.sh',
1130+
'perf/p5304-prune.sh',
1131+
'perf/p5310-pack-bitmaps.sh',
1132+
'perf/p5311-pack-bitmaps-fetch.sh',
1133+
'perf/p5312-pack-bitmaps-revs.sh',
1134+
'perf/p5313-pack-objects.sh',
1135+
'perf/p5314-name-hash.sh',
1136+
'perf/p5326-multi-pack-bitmaps.sh',
1137+
'perf/p5332-multi-pack-reuse.sh',
1138+
'perf/p5333-pseudo-merge-bitmaps.sh',
1139+
'perf/p5550-fetch-tags.sh',
1140+
'perf/p5551-fetch-rescan.sh',
1141+
'perf/p5600-partial-clone.sh',
1142+
'perf/p5601-clone-reference.sh',
1143+
'perf/p6100-describe.sh',
1144+
'perf/p6300-for-each-ref.sh',
1145+
'perf/p7000-filter-branch.sh',
1146+
'perf/p7102-reset.sh',
1147+
'perf/p7300-clean.sh',
1148+
'perf/p7519-fsmonitor.sh',
1149+
'perf/p7527-builtin-fsmonitor.sh',
1150+
'perf/p7810-grep.sh',
1151+
'perf/p7820-grep-engines.sh',
1152+
'perf/p7821-grep-engines-fixed.sh',
1153+
'perf/p7822-grep-perl-character.sh',
1154+
'perf/p9210-scalar.sh',
1155+
'perf/p9300-fast-import-export.sh',
1156+
]
1157+
10991158
# Sanity check that we are not missing any tests present in 't/'. This check
11001159
# only runs once at configure time and is thus best-effort, only. It is
11011160
# sufficient to catch missing test suites in our CI though.
11021161
foreach glob, tests : {
11031162
't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
1163+
'perf/p[0-9][0-9][0-9][0-9]-*.sh': benchmarks,
11041164
'unit-tests/t-*.c': unit_test_programs,
11051165
'unit-tests/u-*.c': clar_test_suites,
11061166
}
@@ -1152,3 +1212,20 @@ foreach integration_test : integration_tests
11521212
timeout: 0,
11531213
)
11541214
endforeach
1215+
1216+
if time.found()
1217+
benchmark_environment = test_environment
1218+
benchmark_environment.set('GTIME', time.full_path())
1219+
1220+
foreach benchmark : benchmarks
1221+
benchmark(fs.stem(benchmark), shell,
1222+
args: [
1223+
fs.name(benchmark),
1224+
],
1225+
workdir: meson.current_source_dir() / 'perf',
1226+
env: benchmark_environment,
1227+
depends: test_dependencies + bin_wrappers,
1228+
timeout: 0,
1229+
)
1230+
endforeach
1231+
endif

0 commit comments

Comments
 (0)