1#!/usr/bin/env bash 2 3set -e 4 5PROGNAME="$(basename "${0}")" 6MONOREPO_ROOT="$(realpath $(dirname "${PROGNAME}"))" 7function usage() { 8cat <<EOF 9Usage: 10${PROGNAME} [-h|--help] <build-directory> benchmarks... 11 12Print the path to the JSON files containing benchmark results for the given benchmarks. 13 14This requires those benchmarks to have already been run, i.e. this only resolves the path 15to the benchmark .json file within the build directory. 16 17<build-directory> The path to the build directory. 18benchmarks... Paths of the benchmarks to extract the results for. Those paths are relative to '<monorepo-root>'. 19 20Example 21======= 22$ cmake -S runtimes -B build/ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" 23$ libcxx-lit build/ -sv libcxx/test/benchmarks/algorithms/for_each.bench.cpp 24$ less \$(${PROGNAME} build/ libcxx/test/benchmarks/algorithms/for_each.bench.cpp) 25EOF 26} 27 28if [[ "${1}" == "-h" || "${1}" == "--help" ]]; then 29 usage 30 exit 0 31fi 32 33if [[ $# -lt 1 ]]; then 34 usage 35 exit 1 36fi 37 38build_dir="${1}" 39shift 40 41for benchmark in ${@}; do 42 # Normalize the paths by turning all benchmarks paths into absolute ones and then making them 43 # relative to the root of the monorepo. 44 benchmark="$(realpath ${benchmark})" 45 relative=$(python -c "import os; import sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))" "${benchmark}" "${MONOREPO_ROOT}") 46 47 # Extract components of the benchmark path 48 directory="$(dirname ${relative})" 49 file="$(basename ${relative})" 50 51 # Reconstruct the (slightly weird) path to the benchmark json file. This should be kept in sync 52 # whenever the test suite changes. 53 json="${build_dir}/${directory}/Output/${file}.dir/benchmark-result.json" 54 if [[ -f "${json}" ]]; then 55 echo "${json}" 56 fi 57done 58