31 lines
481 B
Go
31 lines
481 B
Go
package statistics
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.maximhutz.com/max/lambda/pkg/lambda"
|
|
)
|
|
|
|
type Profiler struct {
|
|
start time.Time
|
|
steps uint64
|
|
Results *Results
|
|
}
|
|
|
|
func (p *Profiler) Start(*lambda.Expression) {
|
|
p.start = time.Now()
|
|
p.steps = 0
|
|
p.Results = nil
|
|
}
|
|
|
|
func (p *Profiler) Step(*lambda.Expression) {
|
|
p.steps++
|
|
}
|
|
|
|
func (p *Profiler) End(*lambda.Expression) {
|
|
p.Results = &Results{
|
|
StepsTaken: p.steps,
|
|
TimeElapsed: uint64(time.Since(p.start).Milliseconds()),
|
|
}
|
|
}
|