2017-01-22 18:53:57 +01: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 11:19:04 +02:00
|
|
|
test_perf 'sort(1) unsorted' '
|
|
|
|
sort <unsorted >sorted
|
2017-01-22 18:53:57 +01:00
|
|
|
'
|
|
|
|
|
2021-10-01 11:19:04 +02:00
|
|
|
test_expect_success 'reverse' '
|
|
|
|
sort -r <unsorted >reversed
|
2017-01-22 18:53:57 +01:00
|
|
|
'
|
|
|
|
|
2021-10-01 11:19:04 +02: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 18:53:57 +01:00
|
|
|
|
2021-10-01 11:19:51 +02:00
|
|
|
for file in unsorted sorted reversed
|
|
|
|
do
|
2022-07-16 18:57:18 +02:00
|
|
|
test_perf "DEFINE_LIST_SORT $file" "
|
2021-10-01 11:19:51 +02:00
|
|
|
test-tool mergesort sort <$file >actual
|
|
|
|
"
|
|
|
|
|
2022-07-16 18:57:18 +02:00
|
|
|
test_expect_success "DEFINE_LIST_SORT $file sorts like sort(1)" "
|
2021-10-01 11:19:51 +02:00
|
|
|
test_cmp_bin sorted actual
|
|
|
|
"
|
|
|
|
done
|
|
|
|
|
2017-01-22 18:53:57 +01:00
|
|
|
test_done
|