Skip to content

Instantly share code, notes, and snippets.

@ayoisaiah
Created October 8, 2020 13:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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