improve package gerror

This commit is contained in:
John Guo 2020-12-11 01:08:15 +08:00
parent 1d1e64b834
commit 0ca305a1bf
3 changed files with 19 additions and 0 deletions

View File

@ -12,10 +12,12 @@ import "runtime"
type stack []uintptr
const (
// maxStackDepth marks the max stack depth for error back traces.
maxStackDepth = 32
)
// callers returns the stack callers.
// Note that it here just retrieves the caller memory address array not the caller information.
func callers(skip ...int) stack {
var (
pcs [maxStackDepth]uintptr

View File

@ -0,0 +1,17 @@
// Copyright GoFrame Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gerror
import (
"testing"
)
func Benchmark_Stack(b *testing.B) {
for i := 0; i < b.N; i++ {
callers()
}
}