Created
June 24, 2016 18:35
-
-
Save brianfoshee/c6c4e22c2bbc2ccd3768653e27ea0106 to your computer and use it in GitHub Desktop.
string concat vs Sprintf bench
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" | |
) | |
var result string | |
func BenchmarkSprintf(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
result = fmt.Sprintf("%s, %s", "hello", "world") | |
} | |
} | |
func BenchmarkStringConcat(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
result = "hello" + ", " + "world" | |
} | |
} |
Author
brianfoshee
commented
Jun 24, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment