summaryrefslogtreecommitdiff
path: root/t/perf
diff options
context:
space:
mode:
authorJohn Cai <johncai86@gmail.com>2022-03-15 02:40:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-03-15 17:15:32 (GMT)
commiteb54a3391bb3bdd6806ebffc21281eae8d9c0dca (patch)
tree84fe0c8ec07b5842f866f840f64080b3aa7a8106 /t/perf
parentc2162907e9aa884bdb70208389cb99b181620d51 (diff)
downloadgit-eb54a3391bb3bdd6806ebffc21281eae8d9c0dca.zip
git-eb54a3391bb3bdd6806ebffc21281eae8d9c0dca.tar.gz
git-eb54a3391bb3bdd6806ebffc21281eae8d9c0dca.tar.bz2
cat-file: skip expanding default format
When format is passed into --batch, --batch-check, --batch-command, the format gets expanded. When nothing is passed in, the default format is set and the expand_format() gets called. We can save on these cycles by hardcoding how to print the information when nothing is passed as the format, or when the default format is passed. There is no need for the fully expanded format with the default. Since batch_object_write() happens on every object provided in batch mode, we get a nice performance improvement. git rev-list --all > /tmp/all-obj.txt git cat-file --batch-check </tmp/all-obj.txt with HEAD^: Time (mean ± σ): 57.6 ms ± 1.7 ms [User: 51.5 ms, System: 6.2 ms] Range (min … max): 54.6 ms … 64.7 ms 50 runs with HEAD: Time (mean ± σ): 49.8 ms ± 1.7 ms [User: 42.6 ms, System: 7.3 ms] Range (min … max): 46.9 ms … 55.9 ms 56 runs If nothing is provided as a format argument, or if the default format is passed, skip expanding of the format and print the object info with a default format. See https://lore.kernel.org/git/87eecf8ork.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/perf')
-rwxr-xr-xt/perf/p1006-cat-file.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/perf/p1006-cat-file.sh b/t/perf/p1006-cat-file.sh
new file mode 100755
index 0000000..dcd8015
--- /dev/null
+++ b/t/perf/p1006-cat-file.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+test_description='Tests listing object info performance'
+. ./perf-lib.sh
+
+test_perf_large_repo
+
+test_perf 'cat-file --batch-check' '
+ git cat-file --batch-all-objects --batch-check
+'
+
+test_done