Created
December 16, 2015 00:06
-
-
Save yifan-gu/5b9321327ffabbd9a2d7 to your computer and use it in GitHub Desktop.
bench time.now
This file contains hidden or 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
$ go test -v -bench=. | |
testing: warning: no tests to run | |
PASS | |
BenchmarkTimenow 100000000 21.8 ns/op | |
This file contains hidden or 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 benchtime | |
import ( | |
"testing" | |
"time" | |
) | |
func BenchmarkTimenow(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
time.Now() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment