func (this *FunServantImpl) profiler() profiler { p := profiler{on: false} p.on = sampling.SampleRateSatisfied(this.conf.ProfilerRate) p.t1 = time.Now() return p }
func (this *session) startProfiler() (*profiler, error) { if this.profiler == nil { if this.ctx.Rid == 0 || this.ctx.Reason == "" { log.Error("Invalid context: %s", this.ctx.String()) return nil, ErrInvalidContext } this.profiler = &profiler{} // TODO 某些web server需要100%采样 this.profiler.on = sampling.SampleRateSatisfied(config.Engine.Servants.ProfilerRate) this.profiler.t0 = time.Now() this.profiler.t1 = this.profiler.t0 } this.profiler.t1 = time.Now() return this.profiler, nil }