Created
March 1, 2021 07:36
-
-
Save C-Pro/065adec5a3211f2ed5a08651ac3345e4 to your computer and use it in GitHub Desktop.
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 main_test | |
| import ( | |
| "testing" | |
| ) | |
| func cmp(a, b string) bool { | |
| if len(a) != len(b) { | |
| return false | |
| } | |
| for i := 0; i < len(a); i++ { | |
| if a[i] != b[i] { | |
| return false | |
| } | |
| } | |
| return true | |
| } | |
| func eq(a, b string) bool { return a == b } | |
| func BenchmarkCmp0(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| cmp("012345", "543210") | |
| } | |
| } | |
| func BenchmarkCmp1(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| cmp("012345", "054321") | |
| } | |
| } | |
| func BenchmarkEQ0(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| eq("012345", "543210") | |
| } | |
| } | |
| func BenchmarkEQ1(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| eq("012345", "054321") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.