1 Star 0 Fork 0

mosache/go-zero

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
profiler.go 979 Bytes
Copy Edit Raw Blame History
kevwan authored 2020-08-08 16:40 +08:00 . update package reference
package prof
import "github.com/tal-tech/go-zero/core/utils"
type (
ProfilePoint struct {
*utils.ElapsedTimer
}
Profiler interface {
Start() ProfilePoint
Report(name string, point ProfilePoint)
}
RealProfiler struct{}
NullProfiler struct{}
)
var profiler = newNullProfiler()
func EnableProfiling() {
profiler = newRealProfiler()
}
func Start() ProfilePoint {
return profiler.Start()
}
func Report(name string, point ProfilePoint) {
profiler.Report(name, point)
}
func newRealProfiler() Profiler {
return &RealProfiler{}
}
func (rp *RealProfiler) Start() ProfilePoint {
return ProfilePoint{
ElapsedTimer: utils.NewElapsedTimer(),
}
}
func (rp *RealProfiler) Report(name string, point ProfilePoint) {
duration := point.Duration()
report(name, duration)
}
func newNullProfiler() Profiler {
return &NullProfiler{}
}
func (np *NullProfiler) Start() ProfilePoint {
return ProfilePoint{}
}
func (np *NullProfiler) Report(string, ProfilePoint) {
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mosache/go-zero.git
git@gitee.com:mosache/go-zero.git
mosache
go-zero
go-zero
dfb45c801a6c

Search