Last active
December 6, 2017 03:27
-
-
Save debnath/05e16ecc0177543f17c7a6b9e6b12703 to your computer and use it in GitHub Desktop.
Failed experiment: strings.join vs buffer.WriteString
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
start := time.Now() | |
/* | |
var buffer bytes.Buffer | |
for _, x := range v { | |
buffer.WriteString(x) | |
buffer.WriteString("::") | |
} | |
test := strings.ToLower(buffer.String()) */ | |
test := strings.ToLower(strings.Join(v[:], "::")) | |
t := time.Now() | |
elapsed := t.Sub(start) | |
f, _ := os.OpenFile("/tmp/joincat", os.O_APPEND|os.O_WRONLY, 0600) | |
e := fmt.Sprintf("%d\n", elapsed.Nanoseconds()) | |
f.WriteString(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Surprisingly, strings.join() was slightly more performant than buffer.WriteString. Oh well.