Created
October 8, 2020 13:31
-
-
Save ayoisaiah/fb2f217590f70a1e6f32003558e7b826 to your computer and use it in GitHub Desktop.
Benchmarking two unique ways to get a filename without the extension in Go
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" | |
) | |
var res string | |
func BenchmarkFileNameWithoutExtSliceNotation(b *testing.B) { | |
// run the Fib function b.N times | |
var r string | |
for n := 0; n < b.N; n++ { | |
r = fileNameWithoutExtSliceNotation("2020-10-06_19-09.png") | |
} | |
res = r | |
} | |
func BenchmarkFileNameWithoutExtTrimSuffix(b *testing.B) { | |
// run the Fib function b.N times | |
var r string | |
for n := 0; n < b.N; n++ { | |
r = fileNameWithoutExtTrimSuffix("2020-10-06_19-09.png") | |
} | |
res = r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment