detached 38230d3

test(ermitegit): add cold and parallel variants to the routing benchmarks

commit
38230d3f4a9a8f222deedb65412a2d08e0a86793
author
brice · · 2026-10-11 00:46 UTC
parent
dbef343
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +34 -1
M internal/adapters/ermitegit/bench_test.go +34 -1
@@ -182,12 +182,21 @@ func BenchmarkRepoReader(b *testing.B) {
182182 return
183183 }},
184184 }
185+ // Each method runs three ways, for both readers: warm (the repository is
186+ // open, one caller), cold (the repository is closed before every call: the
187+ // price of the first read after the idle TTL, an eviction or a restart) and
188+ // parallel (b.RunParallel: the contention of the cache and of the library).
189+ // The CLI reader keeps no repository open, so its cold run is its warm run.
185190 for _, m := range methods {
186191 b.Run(m.name, func(b *testing.B) {
187192 for _, ad := range []struct {
188193 name string
189194 r ports.RepoReader
190- }{{"cli", g}, {"ermitegit", a}} {
195+ cold func() // closes what the reader holds open
196+ }{
197+ {"cli", g, func() {}},
198+ {"ermitegit", a, func() { a.Forget(t.dir) }},
199+ } {
191200 b.Run(ad.name, func(b *testing.B) {
192201 require.NoError(b, m.run(ad.r)) // warm-up: processes, caches, graph
193202 b.ReportAllocs()
@@ -198,6 +207,30 @@ func BenchmarkRepoReader(b *testing.B) {
198207 }
199208 }
200209 })
210+ b.Run(ad.name+"_cold", func(b *testing.B) {
211+ require.NoError(b, m.run(ad.r))
212+ b.ReportAllocs()
213+ b.ResetTimer()
214+ for b.Loop() {
215+ ad.cold()
216+ if err := m.run(ad.r); err != nil {
217+ b.Fatal(err)
218+ }
219+ }
220+ })
221+ b.Run(ad.name+"_parallel", func(b *testing.B) {
222+ require.NoError(b, m.run(ad.r))
223+ b.ReportAllocs()
224+ b.ResetTimer()
225+ b.RunParallel(func(pb *testing.PB) {
226+ for pb.Next() {
227+ if err := m.run(ad.r); err != nil {
228+ b.Error(err)
229+ return
230+ }
231+ }
232+ })
233+ })
201234 }
202235 })
203236 }
@@ -182,12 +182,21 @@ func BenchmarkRepoReader(b *testing.B) {
182 return182 return
183 }},183 }},
184 }184 }
185+ // Each method runs three ways, for both readers: warm (the repository is
186+ // open, one caller), cold (the repository is closed before every call: the
187+ // price of the first read after the idle TTL, an eviction or a restart) and
188+ // parallel (b.RunParallel: the contention of the cache and of the library).
189+ // The CLI reader keeps no repository open, so its cold run is its warm run.
185 for _, m := range methods {190 for _, m := range methods {
186 b.Run(m.name, func(b *testing.B) {191 b.Run(m.name, func(b *testing.B) {
187 for _, ad := range []struct {192 for _, ad := range []struct {
188 name string193 name string
189 r ports.RepoReader194 r ports.RepoReader
190- }{{"cli", g}, {"ermitegit", a}} {195+ cold func() // closes what the reader holds open
196+ }{
197+ {"cli", g, func() {}},
198+ {"ermitegit", a, func() { a.Forget(t.dir) }},
199+ } {
191 b.Run(ad.name, func(b *testing.B) {200 b.Run(ad.name, func(b *testing.B) {
192 require.NoError(b, m.run(ad.r)) // warm-up: processes, caches, graph201 require.NoError(b, m.run(ad.r)) // warm-up: processes, caches, graph
193 b.ReportAllocs()202 b.ReportAllocs()
@@ -198,6 +207,30 @@ func BenchmarkRepoReader(b *testing.B) {
198 }207 }
199 }208 }
200 })209 })
210+ b.Run(ad.name+"_cold", func(b *testing.B) {
211+ require.NoError(b, m.run(ad.r))
212+ b.ReportAllocs()
213+ b.ResetTimer()
214+ for b.Loop() {
215+ ad.cold()
216+ if err := m.run(ad.r); err != nil {
217+ b.Fatal(err)
218+ }
219+ }
220+ })
221+ b.Run(ad.name+"_parallel", func(b *testing.B) {
222+ require.NoError(b, m.run(ad.r))
223+ b.ReportAllocs()
224+ b.ResetTimer()
225+ b.RunParallel(func(pb *testing.PB) {
226+ for pb.Next() {
227+ if err := m.run(ad.r); err != nil {
228+ b.Error(err)
229+ return
230+ }
231+ }
232+ })
233+ })
201 }234 }
202 })235 })
203 }236 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close