Skip to content

Commit e8e5453

Browse files
derrickstoleegitster
authored andcommitted
p6011: add perf test for rev-list --maximal-only
Add a performance test that compares 'git rev-list --maximal-only' against 'git merge-base --independent'. These two commands are asking essentially the same thing, but the rev-list implementation is more generic and hence slower. These performance tests will demonstrate that in the current state and also be used to show the equivalence in the future. We also add a case with '--since' to force the generic walk logic for rev-list even when we make that future change to use the merge-base algorithm on a simple walk. When run on my copy of git.git, I see these results: Test HEAD ---------------------------------------------- 6011.2: merge-base --independent 0.03 6011.3: rev-list --maximal-only 0.06 6011.4: rev-list --maximal-only --since 0.06 These numbers are low, but the --independent calculation is interesting due to having a lot of local branches that are actually independent. Running the same test on a fresh clone of the Linux kernel repository shows a larger difference between the algorithms, especially because the --independent algorithm is extremely fast when there are no independent references selected: Test HEAD ---------------------------------------------- 6011.2: merge-base --independent 0.00 6011.3: rev-list --maximal-only 0.70 6011.4: rev-list --maximal-only --since 0.70 Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 295fb82 commit e8e5453

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

t/perf/p6011-rev-list-maximal.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
test_description='Test --maximal-only and --independent options'
4+
5+
. ./perf-lib.sh
6+
7+
test_perf_default_repo
8+
9+
test_expect_success 'setup' '
10+
git for-each-ref --format="%(*objecttype) %(objecttype) %(objectname)" \
11+
"refs/heads/*" "refs/tags/*" |
12+
sed -n -e "s/^commit commit //p" -e "s/^ commit //p" |
13+
head -n 50 >commits &&
14+
git commit-graph write --reachable
15+
'
16+
17+
test_perf 'merge-base --independent' '
18+
git merge-base --independent $(cat commits) >/dev/null
19+
'
20+
21+
test_perf 'rev-list --maximal-only' '
22+
git rev-list --maximal-only $(cat commits) >/dev/null
23+
'
24+
25+
test_perf 'rev-list --maximal-only --since' '
26+
git rev-list --maximal-only --since=2000-01-01 $(cat commits) >/dev/null
27+
'
28+
29+
test_done

0 commit comments

Comments
 (0)