p0071: measure sorting of already sorted and reversed files

Check if sorting takes advantage of already sorted or reversed content, or if that corner case actually decreases performance, like it would for a simplistic quicksort implementation. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 1, 2021 at 11:19 UTC 84edc40676c5b21df872ec5004a48f706486961f
1 file changed +22 -7
t/perf/p0071-sort.sh
+22 -7
@@ -11,16 +11,31 @@ test_expect_success 'setup' '
11 git cat-file --batch >unsorted
12 '
13
14 -test_perf 'sort(1)' '
15 - sort <unsorted >expect
14 +test_perf 'sort(1) unsorted' '
15 + sort <unsorted >sorted
16 '
17
18 -test_perf 'string_list_sort()' '
19 - test-tool string-list sort <unsorted >actual
18 +test_expect_success 'reverse' '
19 + sort -r <unsorted >reversed
20 '
21
22 -test_expect_success 'string_list_sort() sorts like sort(1)' '
23 - test_cmp_bin expect actual
24 -'
22 +for file in sorted reversed
23 +do
24 + test_perf "sort(1) $file" "
25 + sort <$file >actual
26 + "
27 +done
28 +
29 +for file in unsorted sorted reversed
30 +do
31 +
32 + test_perf "string_list_sort() $file" "
33 + test-tool string-list sort <$file >actual
34 + "
35 +
36 + test_expect_success "string_list_sort() $file sorts like sort(1)" "
37 + test_cmp_bin sorted actual
38 + "
39 +done
40
41 test_done