summaryrefslogtreecommitdiff
path: root/t/perf
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-10-01 09:19:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-10-01 19:43:09 (GMT)
commit84edc40676c5b21df872ec5004a48f706486961f (patch)
tree21926066612493ad93f0e7841f4a5e388946f6aa /t/perf
parentf1ed4ce9e314a7d21229f2fa9004d6faa512293c (diff)
downloadgit-84edc40676c5b21df872ec5004a48f706486961f.zip
git-84edc40676c5b21df872ec5004a48f706486961f.tar.gz
git-84edc40676c5b21df872ec5004a48f706486961f.tar.bz2
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>
Diffstat (limited to 't/perf')
-rwxr-xr-xt/perf/p0071-sort.sh29
1 files changed, 22 insertions, 7 deletions
diff --git a/t/perf/p0071-sort.sh b/t/perf/p0071-sort.sh
index 6e924f5..5b39b68 100755
--- a/t/perf/p0071-sort.sh
+++ b/t/perf/p0071-sort.sh
@@ -11,16 +11,31 @@ test_expect_success 'setup' '
git cat-file --batch >unsorted
'
-test_perf 'sort(1)' '
- sort <unsorted >expect
+test_perf 'sort(1) unsorted' '
+ sort <unsorted >sorted
'
-test_perf 'string_list_sort()' '
- test-tool string-list sort <unsorted >actual
+test_expect_success 'reverse' '
+ sort -r <unsorted >reversed
'
-test_expect_success 'string_list_sort() sorts like sort(1)' '
- test_cmp_bin expect actual
-'
+for file in sorted reversed
+do
+ test_perf "sort(1) $file" "
+ sort <$file >actual
+ "
+done
+
+for file in unsorted sorted reversed
+do
+
+ test_perf "string_list_sort() $file" "
+ test-tool string-list sort <$file >actual
+ "
+
+ test_expect_success "string_list_sort() $file sorts like sort(1)" "
+ test_cmp_bin sorted actual
+ "
+done
test_done