Skip to content

Commit 36e7619

Browse files
committed
fix(octicons): reset cache in cold benchmarks
Fixes #2850
1 parent d1c6af7 commit 36e7619

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

pkg/octicons/octicons_benchmark_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func BenchmarkDataURICache(b *testing.B) {
3030
})
3131
}
3232

33-
// Run each ColdStart inventory separately with -benchtime=1x in a fresh
34-
// `go test` process so package-level cache state cannot cross-contaminate it.
3533
func BenchmarkIconsRegistrationColdStart(b *testing.B) {
3634
benchmarkIconsRegistration(b, false)
3735
}
@@ -51,16 +49,19 @@ func benchmarkIconsRegistration(b *testing.B, warm bool) {
5149
for _, icon := range inventory {
5250
_ = Icons(icon)
5351
}
54-
} else {
55-
dataURIs.mu.Lock()
56-
dataURIs.values = nil
57-
dataURIs.mu.Unlock()
5852
}
5953

6054
batch := make([][]mcp.Icon, len(inventory))
6155
b.ReportAllocs()
6256
b.ResetTimer()
6357
for b.Loop() {
58+
if !warm {
59+
b.StopTimer()
60+
dataURIs.mu.Lock()
61+
dataURIs.values = nil
62+
dataURIs.mu.Unlock()
63+
b.StartTimer()
64+
}
6465
for index, icon := range inventory {
6566
batch[index] = Icons(icon)
6667
}

0 commit comments

Comments
 (0)