Merge branch 'sb/config-write-fix'
[git] / t / perf / p0004-lazy-init-name-hash.sh
1 #!/bin/sh
2
3 test_description='Tests multi-threaded lazy_init_name_hash'
4 . ./perf-lib.sh
5
6 test_perf_large_repo
7 test_checkout_worktree
8
9 test_expect_success 'verify both methods build the same hashmaps' '
10         test-tool lazy-init-name-hash --dump --single >out.single &&
11         if test-tool lazy-init-name-hash --dump --multi >out.multi
12         then
13                 test_set_prereq REPO_BIG_ENOUGH_FOR_MULTI &&
14                 sort <out.single >sorted.single &&
15                 sort <out.multi >sorted.multi &&
16                 test_cmp sorted.single sorted.multi
17         fi
18 '
19
20 test_expect_success 'calibrate' '
21         entries=$(wc -l <out.single) &&
22
23         case $entries in
24         ?) count=1000000 ;;
25         ??) count=100000 ;;
26         ???) count=10000 ;;
27         ????) count=1000 ;;
28         ?????) count=100 ;;
29         ??????) count=10 ;;
30         *) count=1 ;;
31         esac &&
32         export count &&
33
34         case $entries in
35         1) entries_desc="1 entry" ;;
36         *) entries_desc="$entries entries" ;;
37         esac &&
38
39         case $count in
40         1) count_desc="1 round" ;;
41         *) count_desc="$count rounds" ;;
42         esac &&
43
44         desc="$entries_desc, $count_desc" &&
45         export desc
46 '
47
48 test_perf "single-threaded, $desc" "
49         test-tool lazy-init-name-hash --single --count=$count
50 "
51
52 test_perf REPO_BIG_ENOUGH_FOR_MULTI "multi-threaded, $desc" "
53         test-tool lazy-init-name-hash --multi --count=$count
54 "
55
56 test_done