p0004: use test_perf

The perf test suite (more specifically: t/perf/aggregate.perl) requires each test script to write test results into a file, otherwise it aborts when aggregating. Add actual performance tests with test_perf to allow p0004 to be run together with other perf scripts. Calibrate the value for the parameter --count based on the size of the test repository, in order to get meaningful results with smaller repos yet still be able to finish the script against huge ones without having to wait for hours. Signed-off-by: Rene Scharfe <l.s.r@web.de> Acked-by: Jeff Hostetler <git@jeffhostetler.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 13, 2017 at 18:02 UTC 48a6ace8f5a504cea47d4058744982f2bfb81f2f
1 file changed +36
t/perf/p0004-lazy-init-name-hash.sh
+36
@@ -18,4 +18,40 @@ test_expect_success 'multithreaded should be faster' '
18 test-lazy-init-name-hash --perf >out.perf
19 '
20
21 +test_expect_success 'calibrate' '
22 + entries=$(wc -l <out.single) &&
23 +
24 + case $entries in
25 + ?) count=1000000 ;;
26 + ??) count=100000 ;;
27 + ???) count=10000 ;;
28 + ????) count=1000 ;;
29 + ?????) count=100 ;;
30 + ??????) count=10 ;;
31 + *) count=1 ;;
32 + esac &&
33 + export count &&
34 +
35 + case $entries in
36 + 1) entries_desc="1 entry" ;;
37 + *) entries_desc="$entries entries" ;;
38 + esac &&
39 +
40 + case $count in
41 + 1) count_desc="1 round" ;;
42 + *) count_desc="$count rounds" ;;
43 + esac &&
44 +
45 + desc="$entries_desc, $count_desc" &&
46 + export desc
47 +'
48 +
49 +test_perf "single-threaded, $desc" "
50 + test-lazy-init-name-hash --single --count=$count
51 +"
52 +
53 +test_perf "multi-threaded, $desc" "
54 + test-lazy-init-name-hash --multi --count=$count
55 +"
56 +
57 test_done