Skip to content

Commit bb0830c

Browse files
peffgitster
authored andcommitted
t/perf: add tests for git-describe
We don't have a perf script for git-describe, despite it often being accused of slowness. Let's add a few simple tests to start with. Rather than use the existing tags from our test repo, we'll make our own so that we have a known quantity and position. We'll add a "new" tag near the tip of HEAD, and an "old" one that is at the very bottom. And then our tests are: 1. Describing HEAD naively requires walking all the way down to the old tag as we collect candidates. This gives us a baseline for what "slow" looks like. 2. Doing the same with --candidates=1 can potentially be fast, because we can quie after finding "new". But we don't, and it's also slow. 3. Likewise we should be able to quit when there are no more tags to find. This can happen naturally if a repo has few tags, but also if you restrict the set of tags with --match. Here are the results running against linux.git. Note that I have a commit-graph built for the repo, so "slow" here is ~700ms. Without a commit graph it's more like 9s! Test HEAD -------------------------------------------------------------- 6100.2: describe HEAD 0.70(0.66+0.04) 6100.3: describe HEAD with one max candidate 0.70(0.66+0.04) 6100.4: describe HEAD with one tag 0.70(0.64+0.06) Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0e52c1 commit bb0830c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

t/perf/p6100-describe.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
test_description='performance of git-describe'
4+
. ./perf-lib.sh
5+
6+
test_perf_default_repo
7+
8+
# clear out old tags and give us a known state
9+
test_expect_success 'set up tags' '
10+
git for-each-ref --format="delete %(refname)" refs/tags >to-delete &&
11+
git update-ref --stdin <to-delete &&
12+
new=$(git rev-list -1000 HEAD | tail -n 1) &&
13+
git tag -m new new $new &&
14+
old=$(git rev-list HEAD | tail -n 1) &&
15+
git tag -m old old $old
16+
'
17+
18+
test_perf 'describe HEAD' '
19+
git describe HEAD
20+
'
21+
22+
test_perf 'describe HEAD with one max candidate' '
23+
git describe --candidates=1 HEAD
24+
'
25+
26+
test_perf 'describe HEAD with one tag' '
27+
git describe --match=new HEAD
28+
'
29+
30+
test_done

0 commit comments

Comments
 (0)