Benchmarking two unique ways to get a filename without the extension in Go
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