From 8688a31729cfd2f069fc53a5081273d61803a32f Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 17 Jan 2025 09:28:33 -0500 Subject: [PATCH] [libc++] Allow passing arguments to GoogleBenchmark's compare.py tool --- libcxx/utils/libcxx-compare-benchmarks | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/libcxx/utils/libcxx-compare-benchmarks b/libcxx/utils/libcxx-compare-benchmarks index e04820fc57ed..08c53b2420c8 100755 --- a/libcxx/utils/libcxx-compare-benchmarks +++ b/libcxx/utils/libcxx-compare-benchmarks @@ -7,15 +7,16 @@ MONOREPO_ROOT="$(realpath $(dirname "${PROGNAME}"))" function usage() { cat < benchmarks... +${PROGNAME} [-h|--help] benchmarks... [-- gbench-args...] Compare the given benchmarks between the baseline and the candidate build directories. This requires those benchmarks to have already been generated in both build directories. - The path to the build directory considered the baseline. - The path to the build directory considered the candidate. -benchmarks... Paths of the benchmarks to compare. Those paths are relative to ''. + The path to the build directory considered the baseline. + The path to the build directory considered the candidate. +benchmarks... Paths of the benchmarks to compare. Those paths are relative to ''. +[-- gbench-args...] Any arguments provided after '--' will be passed as-is to GoogleBenchmark's compare.py tool. Example ======= @@ -45,7 +46,17 @@ python3 -m venv /tmp/libcxx-compare-benchmarks-venv source /tmp/libcxx-compare-benchmarks-venv/bin/activate pip3 install -r ${GBENCH}/tools/requirements.txt -for benchmark in ${@}; do +benchmarks="" +while [[ $# -gt 0 ]]; do + if [[ "${1}" == "--" ]]; then + shift + break + fi + benchmarks+=" ${1}" + shift +done + +for benchmark in ${benchmarks}; do base="$(${MONOREPO_ROOT}/libcxx/utils/libcxx-benchmark-json ${baseline} ${benchmark})" cand="$(${MONOREPO_ROOT}/libcxx/utils/libcxx-benchmark-json ${candidate} ${benchmark})" @@ -58,5 +69,5 @@ for benchmark in ${@}; do continue fi - "${GBENCH}/tools/compare.py" benchmarks "${base}" "${cand}" + "${GBENCH}/tools/compare.py" benchmarks "${base}" "${cand}" ${@} done