2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-29 08:14:03 +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())
}
}