git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/5] t/perf: fix benchmarks with out-of-tree builds

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 22, 2025, 06:50 UTC
Message-ID
<20250422-pks-meson-benchmarks-v3-3-7aad68bac6fd@pks.im>
In-Reply-To
<20250422-pks-meson-benchmarks-v3-0-7aad68bac6fd@pks.im>

The "perf-lib.sh" script is sourced by all of our benchmarking suites to make available common infrastructure. The script assumes that build and source directory are the same, which works for our Makefile. But the assumption breaks with both CMake and Meson, where the build directory can be located in an arbitrary place.

Adapt the script so that it works with out-of-tree builds. Most importantly, this requires us to figure out the location of the build directory:

  - When running benchmarks via our Makefile the build directory is the
    same as the source directory. We already know to derive the test
    directory ("t/") via `$(pwd)/..`, which works because we chdir into
    "t/perf" before executing benchmarks. We can thus derive the build
    directory by appending another "/.." to that path.
  - When running benchmarks via Meson the build directory is located at
    an arbitrary location. The build system thus has to make the path
    known by exporting the `GIT_BUILD_DIR` environment variable.
This change prepares us for wiring up benchmarks in Meson.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/perf/perf-lib.sh | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 4173eee4def..5406557b7ca 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -25,7 +25,29 @@ TEST_OUTPUT_DIRECTORY=$(pwd)
 TEST_NO_CREATE_REPO=t
 TEST_NO_MALLOC_CHECK=t
 
-. ../test-lib.sh
+# While test-lib.sh computes the build directory for us, we also have to do the
+# same thing in order to locate the script via GIT-BUILD-OPTIONS in the first
+# place.
+GIT_BUILD_DIR="${GIT_BUILD_DIR:-$TEST_DIRECTORY/..}"
+if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR"
+then
+	GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1
+	# On Windows, we must convert Windows paths lest they contain a colon
+	case "$(uname -s)" in
+	*MINGW*)
+		GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")"
+		;;
+	esac
+fi
+
+if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
+then
+	echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).'
+	exit 1
+fi
+
+. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
+. "$GIT_SOURCE_DIR"/t/test-lib.sh
 
 unset GIT_CONFIG_NOSYSTEM
 GIT_CONFIG_SYSTEM="$TEST_DIRECTORY/perf/config"
@@ -324,7 +346,7 @@ test_at_end_hook_ () {
 	if test -z "$GIT_PERF_AGGREGATING_LATER"; then
 		(
 			cd "$TEST_DIRECTORY"/perf &&
-			"$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
+			"$PERL_PATH" "$GIT_SOURCE_DIR"/t/perf/aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
 		)
 	fi
 }
-- 
2.49.0.901.g37484f566f.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 33 of 62 in “meson: wire up support for benchmarks”
  1. 0/5 meson: wire up support for benchmarksPatrick Steinhardt, Mar 31, 2025
  2. 1/5 t/perf: fix benchmarks with alternate repo formatsPatrick Steinhardt, Mar 31, 2025
  3. 2/5 t/perf: use configured PERL_PATHPatrick Steinhardt, Mar 31, 2025
  4. Toon ClaesApr 10, 2025
  5. Patrick SteinhardtApr 14, 2025
  6. Junio C HamanoApr 14, 2025
  7. Patrick SteinhardtApr 15, 2025
  8. 3/5 t/perf: fix benchmarks with out-of-tree buildsPatrick Steinhardt, Mar 31, 2025
  9. Toon ClaesApr 10, 2025
  10. Toon ClaesApr 14, 2025
  11. Patrick SteinhardtApr 14, 2025
  12. 4/5 meson: wire up benchmarksPatrick Steinhardt, Mar 31, 2025
  13. Toon ClaesApr 10, 2025
  14. Patrick SteinhardtApr 14, 2025
  15. Toon ClaesApr 14, 2025
  16. 5/5 meson: wire up benchmarking optionsPatrick Steinhardt, Mar 31, 2025
  17. 0/5 meson: wire up support for benchmarksPatrick Steinhardt, Apr 14, 2025
  18. 1/5 t/perf: fix benchmarks with alternate repo formatsPatrick Steinhardt, Apr 14, 2025
  19. 2/5 t/perf: use configured PERL_PATHPatrick Steinhardt, Apr 14, 2025
  20. 3/5 t/perf: fix benchmarks with out-of-tree buildsPatrick Steinhardt, Apr 14, 2025
  21. Christian CouderApr 20, 2025
  22. Patrick SteinhardtApr 22, 2025
  23. 4/5 meson: wire up benchmarksPatrick Steinhardt, Apr 14, 2025
  24. Christian CouderApr 20, 2025
  25. 5/5 meson: wire up benchmarking optionsPatrick Steinhardt, Apr 14, 2025
  26. Junio C HamanoApr 15, 2025
  27. Junio C HamanoApr 15, 2025
  28. Patrick SteinhardtApr 16, 2025
  29. Junio C HamanoApr 18, 2025
  30. 0/5 meson: wire up support for benchmarksPatrick Steinhardt, Apr 22, 2025
  31. 2/5 t/perf: use configured PERL_PATHPatrick Steinhardt, Apr 22, 2025
  32. 1/5 t/perf: fix benchmarks with alternate repo formatsPatrick Steinhardt, Apr 22, 2025
  33. 3/5 t/perf: fix benchmarks with out-of-tree buildsPatrick Steinhardt, Apr 22, 2025
  34. 4/5 meson: wire up benchmarksPatrick Steinhardt, Apr 22, 2025
  35. 5/5 meson: wire up benchmarking optionsPatrick Steinhardt, Apr 22, 2025
  36. Christian CouderApr 22, 2025
  37. Patrick SteinhardtApr 22, 2025
  38. Christian CouderApr 23, 2025
  39. Patrick SteinhardtApr 24, 2025
  40. Christian CouderApr 24, 2025
  41. Junio C HamanoApr 24, 2025
  42. Patrick SteinhardtApr 24, 2025
  43. Toon ClaesApr 23, 2025
  44. 0/5 meson: wire up support for benchmarksPatrick Steinhardt, Apr 25, 2025
  45. 1/5 t/perf: fix benchmarks with alternate repo formatsPatrick Steinhardt, Apr 25, 2025
  46. 2/5 t/perf: use configured PERL_PATHPatrick Steinhardt, Apr 25, 2025
  47. 3/5 t/perf: fix benchmarks with out-of-tree buildsPatrick Steinhardt, Apr 25, 2025
  48. 4/5 meson: wire up benchmarksPatrick Steinhardt, Apr 25, 2025
  49. Christian CouderApr 25, 2025
  50. Patrick SteinhardtApr 25, 2025
  51. Christian CouderApr 25, 2025
  52. Patrick SteinhardtApr 25, 2025
  53. 5/5 meson: wire up benchmarking optionsPatrick Steinhardt, Apr 25, 2025
  54. Christian CouderApr 25, 2025
  55. Patrick SteinhardtApr 25, 2025
  56. Christian CouderApr 25, 2025
  57. 0/5 meson: wire up support for benchmarksPatrick Steinhardt, Apr 28, 2025
  58. 1/5 t/perf: fix benchmarks with alternate repo formatsPatrick Steinhardt, Apr 28, 2025
  59. 2/5 t/perf: use configured PERL_PATHPatrick Steinhardt, Apr 28, 2025
  60. 3/5 t/perf: fix benchmarks with out-of-tree buildsPatrick Steinhardt, Apr 28, 2025
  61. 4/5 meson: wire up benchmarksPatrick Steinhardt, Apr 28, 2025
  62. 5/5 meson: wire up benchmarking optionsPatrick Steinhardt, Apr 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.