mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +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
1 changed files with 34 additions and 0 deletions
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 a new issue