internal/rosa: drop caches
Some checks failed
Test / Create distribution (push) Successful in 1m18s
Test / Sandbox (push) Successful in 3m12s
Test / Hakurei (push) Successful in 4m23s
Test / ShareFS (push) Successful in 4m29s
Test / Sandbox (race detector) (push) Successful in 5m45s
Test / Hakurei (race detector) (push) Successful in 6m54s
Test / Flake checks (push) Has been cancelled
Some checks failed
Test / Create distribution (push) Successful in 1m18s
Test / Sandbox (push) Successful in 3m12s
Test / Hakurei (push) Successful in 4m23s
Test / ShareFS (push) Successful in 4m29s
Test / Sandbox (race detector) (push) Successful in 5m45s
Test / Hakurei (race detector) (push) Successful in 6m54s
Test / Flake checks (push) Has been cancelled
This enables accurate benchmarking of the toolchain abstraction. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -307,6 +307,17 @@ var (
|
||||
artifactsOnce [_toolchainEnd][len(artifactsM)]sync.Once
|
||||
)
|
||||
|
||||
// zero zeros the value pointed to by p.
|
||||
func zero[T any](p *T) { var v T; *p = v }
|
||||
|
||||
// DropCaches arranges for all cached [pkg.Artifact] to be freed some time after
|
||||
// it returns. Must not be used concurrently with any other function from this
|
||||
// package.
|
||||
func DropCaches() {
|
||||
zero(&artifacts)
|
||||
zero(&artifactsOnce)
|
||||
}
|
||||
|
||||
// GetMetadata returns [Metadata] of a [PArtifact].
|
||||
func GetMetadata(p PArtifact) *Metadata { return &artifactsM[p] }
|
||||
|
||||
|
||||
@@ -91,3 +91,13 @@ func TestCureAll(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkStage3(b *testing.B) {
|
||||
for b.Loop() {
|
||||
rosa.Std.Load(rosa.LLVMClang)
|
||||
|
||||
b.StopTimer()
|
||||
rosa.DropCaches()
|
||||
b.StartTimer()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user