Re: [PATCH 2/4] cat-file: use strbuf_add_uint()
- From
Jeff King <peff@peff.net>
- Date
- May 12, 2026, 18:46 UTC
- Message-ID
- <20260512184619.GD70851@coredump.intra.peff.net>
- In-Reply-To
- <20260512115603.80780-3-l.s.r@web.de>
On Tue, May 12, 2026 at 01:56:01PM +0200, René Scharfe wrote:
Show 11 quoted lines
> Benchmark 1: ./git_main cat-file --batch-all-objects --batch-check='%(objectsize)' > Time (mean ± σ): 751.7 ms ± 1.5 ms [User: 733.5 ms, System: 17.1 ms] > Range (min … max): 750.5 ms … 755.0 ms 10 runs > > Benchmark 2: ./git cat-file --batch-all-objects --batch-check='%(objectsize)' > Time (mean ± σ): 720.4 ms ± 0.4 ms [User: 701.9 ms, System: 16.7 ms] > Range (min … max): 719.7 ms … 721.2 ms 10 runs > > Summary > ./git cat-file --batch-all-objects --batch-check='%(objectsize)' ran > 1.04 ± 0.00 times faster than ./git_main cat-file --batch-all-objects --batch-check='%(objectsize)'
Neat. It is sad that sprintf is so slow that this makes a difference. ;)
But it seems like an easy win, and I would argue the resulting code is more readable here.
-Peff