Skip to content

Commit 84edc40

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1ed4ce commit 84edc40

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

t/perf/p0071-sort.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,31 @@ test_expect_success 'setup' '
1111
git cat-file --batch >unsorted
1212
'
1313

14-
test_perf 'sort(1)' '
15-
sort <unsorted >expect
14+
test_perf 'sort(1) unsorted' '
15+
sort <unsorted >sorted
1616
'
1717

18-
test_perf 'string_list_sort()' '
19-
test-tool string-list sort <unsorted >actual
18+
test_expect_success 'reverse' '
19+
sort -r <unsorted >reversed
2020
'
2121

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
2540

2641
test_done

0 commit comments

Comments
 (0)