2017-01-22 17:53:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='Basic sort performance tests'
|
|
|
|
. ./perf-lib.sh
|
|
|
|
|
|
|
|
test_perf_default_repo
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
git ls-files --stage "*.[ch]" "*.sh" |
|
|
|
|
cut -f2 -d" " |
|
|
|
|
git cat-file --batch >unsorted
|
|
|
|
'
|
|
|
|
|
2021-10-01 09:19:04 +00:00
|
|
|
test_perf 'sort(1) unsorted' '
|
|
|
|
sort <unsorted >sorted
|
2017-01-22 17:53:57 +00:00
|
|
|
'
|
|
|
|
|
2021-10-01 09:19:04 +00:00
|
|
|
test_expect_success 'reverse' '
|
|
|
|
sort -r <unsorted >reversed
|
2017-01-22 17:53:57 +00:00
|
|
|
'
|
|
|
|
|
2021-10-01 09:19:04 +00:00
|
|
|
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
|
2017-01-22 17:53:57 +00:00
|
|
|
|
2021-10-01 09:19:51 +00:00
|
|
|
for file in unsorted sorted reversed
|
|
|
|
do
|
2022-07-16 16:57:18 +00:00
|
|
|
test_perf "DEFINE_LIST_SORT $file" "
|
2021-10-01 09:19:51 +00:00
|
|
|
test-tool mergesort sort <$file >actual
|
|
|
|
"
|
|
|
|
|
2022-07-16 16:57:18 +00:00
|
|
|
test_expect_success "DEFINE_LIST_SORT $file sorts like sort(1)" "
|
2021-10-01 09:19:51 +00:00
|
|
|
test_cmp_bin sorted actual
|
|
|
|
"
|
|
|
|
done
|
|
|
|
|
2017-01-22 17:53:57 +00:00
|
|
|
test_done
|