git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] for-each-ref: add --count-matches option

From
Derrick Stolee <derrickstolee@github.com>
Date
Jul 10, 2023, 16:51 UTC
Message-ID
<4715a469-8c68-8dcc-0254-9b7b857c3722@github.com>
In-Reply-To
<20230627073007.GD1226768@coredump.intra.peff.net>
On 6/27/2023 1:30 AM, Jeff King wrote:
Show 21 quoted lines
>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
>
>is much better (obviously you have to remember to do that if you care
>about optimizing your command, but that's true of --count-matches, too).

Thank you for pointing this out! I'll be sure to modify the test and the analysis about it. The other check I need to compare is when multiple refspecs are provided at the same time, which I do believe still is a valuable thing to combine into a single process instead of multiple pipes to 'wc'. Did you have any thoughts on whether or not this works as an option in 'git for-each-ref' or would be better broken into a new builtin? Thanks, -Stolee

Previous: René ScharfeNext: Derrick Stolee via GitGitGadget
Message 11 of 12 in “[RFC] for-each-ref: add --count-matches mode”
  1. 0/2 [RFC] for-each-ref: add --count-matches modeDerrick Stolee via GitGitGadget, Jun 26, 2023
  2. 2/2 for-each-ref: add --count-matches optionDerrick Stolee via GitGitGadget, Jun 26, 2023
  3. Junio C HamanoJun 26, 2023
  4. Jeff KingJun 27, 2023
  5. Phillip WoodJun 27, 2023
  6. Junio C HamanoJun 27, 2023
  7. Jeff KingJun 27, 2023
  8. Phillip WoodJun 28, 2023
  9. Junio C HamanoJun 28, 2023
  10. René ScharfeJul 11, 2023
  11. Derrick StoleeJul 10, 2023
  12. 1/2 for-each-ref: extract ref output loopDerrick Stolee via GitGitGadget, Jun 26, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.