From: "René Scharfe" <l.s.r@web.de>
To: phillip.wood@dunelm.org.uk, Jeff King <peff@peff.net>,
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, vdye@github.com, me@ttaylorr.com,
mjcheetham@outlook.com, Derrick Stolee <derrickstolee@github.com>
Subject: Re: [PATCH 2/2] for-each-ref: add --count-matches option
Date: Tue, 11 Jul 2023 16:48:29 +0200 [thread overview]
Message-ID: <e77ff965-cad1-dee3-a0a4-aa41249a875d@web.de> (raw)
In-Reply-To: <f6fd39bc-65d4-76e3-94b4-9163194c89dd@gmail.com>
Am 27.06.23 um 12:05 schrieb Phillip Wood:
> On 27/06/2023 08:30, Jeff King wrote:
>> On Mon, Jun 26, 2023 at 03:09:57PM +0000, Derrick Stolee via GitGitGadget wrote:
>>
>>> +for pattern in "refs/heads/" "refs/tags/" "refs/remotes"
>>> +do
>>> + test_perf "count $pattern: git for-each-ref | wc -l" "
>>> + git for-each-ref $pattern | wc -l
>>> + "
>>> +
>>> + test_perf "count $pattern: git for-each-ref --count-match" "
>>> + git for-each-ref --count-matches $pattern
>>> + "
>>> +done
>>
>> I don't think this is a very realistic perf test, because for-each-ref
>> is doing a bunch of work to generate its default format, only to have
>> "wc" throw most of it away. Doing:
>>
>> git for-each-ref --format='%(refname)' | wc -l
>
> That's a good point. I wondered if using a short fixed format string was even better so I tried
>
> git init test
> cd test
> git commit --allow-empty -m initial
> seq 0 100000 | sed "s:\(.*\):create refs/heads/some-prefix/\1 $(git rev-parse HEAD):" | git update-ref --stdin
> git pack-refs --all
> hyperfine -L fmt "","--format=%\(refname\)","--format=x" 'git for-each-ref {fmt} refs/heads/ | wc -l'
>
> Which gives
>
> Benchmark 1: git for-each-ref refs/heads/ | wc -l
> Time (mean ± σ): 1.150 s ± 0.010 s [User: 0.494 s, System: 0.637 s]
> Range (min … max): 1.140 s … 1.170 s 10 runs
>
> Benchmark 2: git for-each-ref --format=%\(refname\) refs/heads/ | wc -l
> Time (mean ± σ): 66.0 ms ± 0.3 ms [User: 58.9 ms, System: 9.5 ms]
> Range (min … max): 65.2 ms … 67.1 ms 43 runs
>
> Benchmark 3: git for-each-ref --format=x refs/heads/ | wc -l
> Time (mean ± σ): 63.0 ms ± 0.5 ms [User: 54.3 ms, System: 9.6 ms]
> Range (min … max): 62.3 ms … 65.4 ms 44 runs
>
> Summary
> git for-each-ref --format=x refs/heads/ | wc -l ran
> 1.05 ± 0.01 times faster than git for-each-ref --format=%\(refname\) refs/heads/ | wc -l
> 18.25 ± 0.20 times faster than git for-each-ref refs/heads/ | wc -l
You don't need no "x", by the way; using the empty string saves some
cycles for me. In my Git clone, no special setup, 9931 refs:
Benchmark 1: git for-each-ref --format=x | wc -l
Time (mean ± σ): 25.1 ms ± 0.1 ms [User: 8.7 ms, System: 16.8 ms]
Range (min … max): 24.9 ms … 25.6 ms 109 runs
Benchmark 2: git for-each-ref --format= | wc -l
Time (mean ± σ): 24.6 ms ± 0.1 ms [User: 8.3 ms, System: 16.8 ms]
Range (min … max): 24.4 ms … 25.3 ms 110 runs
Summary
git for-each-ref --format= | wc -l ran
1.02 ± 0.01 times faster than git for-each-ref --format=x | wc -l
René
next prev parent reply other threads:[~2023-07-11 14:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 15:09 [PATCH 0/2] [RFC] for-each-ref: add --count-matches mode Derrick Stolee via GitGitGadget
2023-06-26 15:09 ` [PATCH 1/2] for-each-ref: extract ref output loop Derrick Stolee via GitGitGadget
2023-06-26 15:09 ` [PATCH 2/2] for-each-ref: add --count-matches option Derrick Stolee via GitGitGadget
2023-06-26 16:14 ` Junio C Hamano
2023-06-27 7:30 ` Jeff King
2023-06-27 10:05 ` Phillip Wood
2023-06-27 18:22 ` Junio C Hamano
2023-06-27 19:59 ` Jeff King
2023-06-28 13:12 ` Phillip Wood
2023-06-28 17:08 ` Junio C Hamano
2023-07-11 14:48 ` René Scharfe [this message]
2023-07-10 16:51 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e77ff965-cad1-dee3-a0a4-aa41249a875d@web.de \
--to=l.s.r@web.de \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=mjcheetham@outlook.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=vdye@github.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).