Created
August 20, 2020 17:56
-
-
Save hamakn/15d99c685223a67fe001b61d80afeb35 to your computer and use it in GitHub Desktop.
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 ( | |
"testing" | |
"time" | |
) | |
func BenchmarkTimeDate(b *testing.B) { | |
now := time.Now() | |
b.ResetTimer() | |
b.ReportAllocs() | |
for n := 0; n < b.N; n++ { | |
now.Date() | |
} | |
} | |
func BenchmarkTimeYearMonthDay(b *testing.B) { | |
now := time.Now() | |
b.ResetTimer() | |
b.ReportAllocs() | |
for n := 0; n < b.N; n++ { | |
now.Year() | |
now.Month() | |
now.Day() | |
} | |
} |
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
% go test -bench . -benchmem --tags=parallel [~/dev/src/github.com/kouzoh/merpay-api:2:52] | |
goos: darwin | |
goarch: amd64 | |
BenchmarkTimeDate-4 45085794 24.1 ns/op 0 B/op 0 allocs/op | |
BenchmarkTimeYearMonthDay-4 19379534 62.1 ns/op 0 B/op 0 allocs/op | |
PASS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment