diff options
author | John Cai <johncai86@gmail.com> | 2022-03-15 02:40:36 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-15 10:15:32 -0700 |
commit | eb54a3391bb3bdd6806ebffc21281eae8d9c0dca (patch) | |
tree | 84fe0c8ec07b5842f866f840f64080b3aa7a8106 /t/t0002-gitfile.sh | |
parent | The ninth batch (diff) | |
download | tgif-eb54a3391bb3bdd6806ebffc21281eae8d9c0dca.tar.xz |
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/t0002-gitfile.sh')
0 files changed, 0 insertions, 0 deletions