1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 00:07:25 +00:00

debug/log: Add benchmarks for calling the logging function

Add some benchmarks for calling Log, both with a static string
along with calling the ID.Str and ID.String functions.
This commit is contained in:
Matthew Dawson 2018-01-21 23:26:47 -05:00
parent 3789e55e20
commit fe33c05a20
No known key found for this signature in database
GPG key ID: 404D7F645F682028

View file

@ -0,0 +1,34 @@
package debug_test
import (
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/restic"
"testing"
)
func BenchmarkLogStatic(b *testing.B) {
for i := 0; i < b.N; i++ {
debug.Log("Static string")
}
}
func BenchmarkLogIDStr(b *testing.B) {
id := restic.NewRandomID()
b.ResetTimer()
for i := 0; i < b.N; i++ {
debug.Log("id: %v", id.Str())
}
}
func BenchmarkLogIDString(b *testing.B) {
id := restic.NewRandomID()
b.ResetTimer()
for i := 0; i < b.N; i++ {
debug.Log("id: %v", id.String())
}
}