Created
June 6, 2011 15:43
-
-
Save kylelemons/1010494 to your computer and use it in GitHub Desktop.
Benchmark function calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
func readonly() {} | |
var readwrite = func() {} | |
func main() { | |
fmt.Printf("readonly: %s\n", testing.Benchmark(func(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
readonly() | |
} | |
})) | |
fmt.Printf("readwrite: %s\n", testing.Benchmark(func(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
readwrite() | |
} | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment