Measure delivery output and version costs
This commit is contained in:
31
internal/runtimeinfo/performance_test.go
Normal file
31
internal/runtimeinfo/performance_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package runtimeinfo
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var performanceVersionSink string
|
||||
|
||||
func BenchmarkPerformanceVersion(b *testing.B) {
|
||||
b.Run("Injected", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
performanceVersionSink = version("v1.2.3", debug.ReadBuildInfo)
|
||||
if performanceVersionSink != "v1.2.3" {
|
||||
b.Fatalf("version() = %q, want injected version", performanceVersionSink)
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("RealMetadataFallback", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
performanceVersionSink = Version()
|
||||
if performanceVersionSink == "" {
|
||||
b.Fatal("Version() returned an empty version")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user