path: root/t/perf
diff options
authorJohn Cai <>2022-03-15 02:40:36 (GMT)
committerJunio C Hamano <>2022-03-15 17:15:32 (GMT)
commiteb54a3391bb3bdd6806ebffc21281eae8d9c0dca (patch)
tree84fe0c8ec07b5842f866f840f64080b3aa7a8106 /t/perf
parentc2162907e9aa884bdb70208389cb99b181620d51 (diff)
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 Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: John Cai <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/perf')
1 files changed, 12 insertions, 0 deletions
diff --git a/t/perf/ b/t/perf/
new file mode 100755
index 0000000..dcd8015
--- /dev/null
+++ b/t/perf/
@@ -0,0 +1,12 @@
+test_description='Tests listing object info performance'
+. ./
+test_perf 'cat-file --batch-check' '
+ git cat-file --batch-all-objects --batch-check