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

Re: [PATCH 1/6] t/perf-lib: factor boilerplate out of test_perf

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 26, 2014, 22:34 UTC
Message-ID
<xmqqr45oh9n4.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140326072232.GA32193@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> About half of test_perf() is boilerplate, and half is
> actually related to running the perf test. Let's split it
> into two functions, so that we can reuse the boilerplate in
> future commits.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/perf/perf-lib.sh | 61 +++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 35 insertions(+), 26 deletions(-)

These early steps somewhat conflict with another topic that is stalled (due to having no real users) on 'pu'. I do not think we would terribly mind dropping tg/perf-lib-test-perf-cleanup and have it rebased if the author or somebody else wants to have it in my tree later, but just FYI.

Show 85 quoted lines
>
> diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
> index a8c9574..20f306a 100644
> --- a/t/perf/perf-lib.sh
> +++ b/t/perf/perf-lib.sh
> @@ -150,8 +150,8 @@ exit $ret' >&3 2>&4
>  	return "$eval_ret"
>  }
>  
> -
> -test_perf () {
> +test_wrapper_ () {
> +	test_wrapper_func_=$1; shift
>  	test_start_
>  	test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
>  	test "$#" = 2 ||
> @@ -162,35 +162,44 @@ test_perf () {
>  		base=$(basename "$0" .sh)
>  		echo "$test_count" >>"$perf_results_dir"/$base.subtests
>  		echo "$1" >"$perf_results_dir"/$base.$test_count.descr
> -		if test -z "$verbose"; then
> -			printf "%s" "perf $test_count - $1:"
> -		else
> -			echo "perf $test_count - $1:"
> -		fi
> -		for i in $(test_seq 1 $GIT_PERF_REPEAT_COUNT); do
> -			say >&3 "running: $2"
> -			if test_run_perf_ "$2"
> -			then
> -				if test -z "$verbose"; then
> -					printf " %s" "$i"
> -				else
> -					echo "* timing run $i/$GIT_PERF_REPEAT_COUNT:"
> -				fi
> +		base="$perf_results_dir"/"$perf_results_prefix$(basename "$0" .sh)"."$test_count"
> +		"$test_wrapper_func_" "$@"
> +	fi
> +
> +	test_finish_
> +}
> +
> +test_perf_ () {
> +	if test -z "$verbose"; then
> +		printf "%s" "perf $test_count - $1:"
> +	else
> +		echo "perf $test_count - $1:"
> +	fi
> +	for i in $(test_seq 1 $GIT_PERF_REPEAT_COUNT); do
> +		say >&3 "running: $2"
> +		if test_run_perf_ "$2"
> +		then
> +			if test -z "$verbose"; then
> +				printf " %s" "$i"
>  			else
> -				test -z "$verbose" && echo
> -				test_failure_ "$@"
> -				break
> +				echo "* timing run $i/$GIT_PERF_REPEAT_COUNT:"
>  			fi
> -		done
> -		if test -z "$verbose"; then
> -			echo " ok"
>  		else
> -			test_ok_ "$1"
> +			test -z "$verbose" && echo
> +			test_failure_ "$@"
> +			break
>  		fi
> -		base="$perf_results_dir"/"$perf_results_prefix$(basename "$0" .sh)"."$test_count"
> -		"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
> +	done
> +	if test -z "$verbose"; then
> +		echo " ok"
> +	else
> +		test_ok_ "$1"
>  	fi
> -	test_finish_
> +	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
> +}
> +
> +test_perf () {
> +	test_wrapper_ test_perf_ "$@"
>  }
>  
>  # We extend test_done to print timings at the end (./run disables this
Previous: Jeff KingNext: Jeff King
Message 3 of 17 in “reuse deltas found by bitmaps”
  1. 0/6 reuse deltas found by bitmapsJeff King, Mar 26, 2014
  2. 1/6 t/perf-lib: factor boilerplate out of test_perfJeff King, Mar 26, 2014
  3. Junio C HamanoMar 26, 2014
  4. 2/6 t/perf/aggregate: factor our percent calculationsJeff King, Mar 26, 2014
  5. 3/6 t/perf: add infrastructure for measuring sizesJeff King, Mar 26, 2014
  6. 4/6 t/perf: add perf tests for fetches from a bitmapped serverJeff King, Mar 26, 2014
  7. 5/6 pack-bitmap: save "have" bitmap from walkJeff King, Mar 26, 2014
  8. 6/6 pack-objects: reuse deltas for thin "have" objectsJeff King, Mar 26, 2014
  9. Eric SunshineMar 28, 2014
  10. Junio C HamanoMar 26, 2014
  11. Jeff KingMar 26, 2014
  12. Junio C HamanoMar 26, 2014
  13. Jeff KingMar 26, 2014
  14. Jeff KingMar 27, 2014
  15. Junio C HamanoMar 27, 2014
  16. Siddharth AgarwalMar 26, 2014
  17. Siddharth AgarwalMar 27, 2014

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.