Imported Upstream version 2.0.1
[platform/upstream/git.git] / t / perf / perf-lib.sh
index a816fbc..a8c9574 100644 (file)
@@ -1,4 +1,6 @@
-#!/bin/sh
+# Performance testing framework.  Each perf script starts much like
+# a normal test script, except it sources this library instead of
+# test-lib.sh.  See t/perf/README for documentation.
 #
 # Copyright (c) 2011 Thomas Rast
 #
@@ -150,6 +152,7 @@ exit $ret' >&3 2>&4
 
 
 test_perf () {
+       test_start_
        test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-success"
@@ -160,7 +163,7 @@ test_perf () {
                echo "$test_count" >>"$perf_results_dir"/$base.subtests
                echo "$1" >"$perf_results_dir"/$base.$test_count.descr
                if test -z "$verbose"; then
-                       echo -n "perf $test_count - $1:"
+                       printf "%s" "perf $test_count - $1:"
                else
                        echo "perf $test_count - $1:"
                fi
@@ -169,7 +172,7 @@ test_perf () {
                        if test_run_perf_ "$2"
                        then
                                if test -z "$verbose"; then
-                                       echo -n " $i"
+                                       printf " %s" "$i"
                                else
                                        echo "* timing run $i/$GIT_PERF_REPEAT_COUNT:"
                                fi
@@ -187,7 +190,7 @@ test_perf () {
                base="$perf_results_dir"/"$perf_results_prefix$(basename "$0" .sh)"."$test_count"
                "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
        fi
-       echo >&3 ""
+       test_finish_
 }
 
 # We extend test_done to print timings at the end (./run disables this