mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
improve package gerror
This commit is contained in:
parent
1d1e64b834
commit
0ca305a1bf
@ -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
|
||||
|
17
errors/gerror/gerror_z_bench_test.go
Normal file
17
errors/gerror/gerror_z_bench_test.go
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user