Skip to content

Instantly share code, notes, and snippets.

@fmstephe
Last active March 20, 2019 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmstephe/a23ddff062f3b96df5e634ccf21e0106 to your computer and use it in GitHub Desktop.
Save fmstephe/a23ddff062f3b96df5e634ccf21e0106 to your computer and use it in GitHub Desktop.
package main
import (
"testing"
)
/*
goos: darwin
goarch: amd64
pkg: github.com/fmstephe/test_empty_method
BenchmarkDebugNoop-4 100000000 18.4 ns/op 8 B/op 1 allocs/op
BenchmarkDebugNoop_NoArgs-4 2000000000 0.42 ns/op 0 B/op 0 allocs/op
*/
func BenchmarkDebugNoop(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Debugf("This does nothing %d", i)
}
}
func BenchmarkDebugNoop_NoArgs(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Debugf("This is also does nothing")
}
}
func Debugf(s string, a ...interface{}) {} // disable debug logs unless `debug` tag is provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment