Skip to content

Commit ac4374e

Browse files
committed
Add baseline benchmark.
1 parent f2a5016 commit ac4374e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

stack_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"path"
77
"path/filepath"
88
"runtime"
9+
"strings"
910
"testing"
1011

1112
"github.com/go-stack/stack"
@@ -259,6 +260,17 @@ func BenchmarkRuntimeCaller(b *testing.B) {
259260
}
260261
}
261262

263+
func BenchmarkRuntimeCallerAndFmt(b *testing.B) {
264+
for i := 0; i < b.N; i++ {
265+
_, file, line, _ := runtime.Caller(0)
266+
const sep = "/"
267+
if i := strings.LastIndex(file, sep); i != -1 {
268+
file = file[i+len(sep):]
269+
}
270+
fmt.Fprint(ioutil.Discard, file, ":", line)
271+
}
272+
}
273+
262274
func BenchmarkFuncForPC(b *testing.B) {
263275
pc, _, _, _ := runtime.Caller(0)
264276
pc--

0 commit comments

Comments
 (0)