Merge branch 'l10n-de-2.40' of github.com:ralfth/git
[alt-git.git] / t / perf / p0008-odb-fsync.sh
blobb3a90f30eba25e8b60eb44bf6a9fbf9c14bf76ba
1 #!/bin/sh
3 # This test measures the performance of adding new files to the object
4 # database. The test was originally added to measure the effect of the
5 # core.fsyncMethod=batch mode, which is why we are testing different values of
6 # that setting explicitly and creating a lot of unique objects.
8 test_description="Tests performance of adding things to the object database"
10 . ./perf-lib.sh
12 . $TEST_DIRECTORY/lib-unique-files.sh
14 test_perf_fresh_repo
15 test_checkout_worktree
17 dir_count=10
18 files_per_dir=50
19 total_files=$((dir_count * files_per_dir))
21 populate_files () {
22 test_create_unique_files $dir_count $files_per_dir files
25 setup_repo () {
26 (rm -rf .git || 1) &&
27 git init &&
28 test_commit first &&
29 populate_files
32 test_perf_fsync_cfgs () {
33 local method &&
34 local cfg &&
35 for method in none fsync batch writeout-only
37 case $method in
38 none)
39 cfg="-c core.fsync=none"
42 cfg="-c core.fsync=loose-object -c core.fsyncMethod=$method"
43 esac &&
45 # Set GIT_TEST_FSYNC=1 explicitly since fsync is normally
46 # disabled by t/test-lib.sh.
47 if ! test_perf "$1 (fsyncMethod=$method)" \
48 --setup "$2" \
49 "GIT_TEST_FSYNC=1 git $cfg $3"
50 then
51 break
53 done
56 test_perf_fsync_cfgs "add $total_files files" \
57 "setup_repo" \
58 "add -- files"
60 test_perf_fsync_cfgs "stash $total_files files" \
61 "setup_repo" \
62 "stash push -u -- files"
64 test_perf_fsync_cfgs "unpack $total_files files" \
66 setup_repo &&
67 git -c core.fsync=none add -- files &&
68 git -c core.fsync=none commit -q -m second &&
69 echo HEAD | git pack-objects -q --stdout --revs >test_pack.pack &&
70 setup_repo
71 " \
72 "unpack-objects -q <test_pack.pack"
74 test_perf_fsync_cfgs "commit $total_files files" \
76 setup_repo &&
77 git -c core.fsync=none add -- files &&
78 populate_files
79 " \
80 "commit -q -a -m test"
82 test_done