From eb54a3391bb3bdd6806ebffc21281eae8d9c0dca Mon Sep 17 00:00:00 2001 From: John Cai Date: Tue, 15 Mar 2022 02:40:36 +0000 Subject: cat-file: skip expanding default format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/perf/p1006-cat-file.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 t/perf/p1006-cat-file.sh (limited to 't/perf') diff --git a/t/perf/p1006-cat-file.sh b/t/perf/p1006-cat-file.sh new file mode 100755 index 0000000000..dcd8015379 --- /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 -- cgit v1.2.3