diff --git a/errors/gerror/gerror_stack.go b/errors/gerror/gerror_stack.go index bcf54cad3..d5fbb3ffb 100644 --- a/errors/gerror/gerror_stack.go +++ b/errors/gerror/gerror_stack.go @@ -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 diff --git a/errors/gerror/gerror_z_bench_test.go b/errors/gerror/gerror_z_bench_test.go new file mode 100644 index 000000000..6877780d8 --- /dev/null +++ b/errors/gerror/gerror_z_bench_test.go @@ -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() + } +} diff --git a/errors/gerror/gerror_test.go b/errors/gerror/gerror_z_unit_test.go similarity index 100% rename from errors/gerror/gerror_test.go rename to errors/gerror/gerror_z_unit_test.go