| 229 | } |
| 230 | |
| 231 | func (p cpuProfiler) After(ctx context.Context, mod api.Module, def api.FunctionDefinition, _ []uint64) { |
| 232 | i := len(p.frames) - 1 |
| 233 | f := p.frames[i] |
| 234 | p.frames = p.frames[:i] |
| 235 | |
| 236 | if f.start != 0 { |
| 237 | duration := p.time() - f.start |
| 238 | if i := len(p.frames); i > 0 { |
| 239 | p.frames[i-1].sub += duration |
| 240 | } |
| 241 | duration -= f.sub |
| 242 | p.mutex.Lock() |
| 243 | if p.counts != nil { |
| 244 | p.counts.observe(f.trace, duration) |
| 245 | } |
| 246 | p.mutex.Unlock() |
| 247 | p.traces = append(p.traces, f.trace) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | func (p cpuProfiler) Abort(ctx context.Context, mod api.Module, def api.FunctionDefinition, _ error) { |
| 252 | p.After(ctx, mod, def, nil) |