mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +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:
parent
3789e55e20
commit
fe33c05a20
34
internal/debug/log_test.go
Normal file
34
internal/debug/log_test.go
Normal 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())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user