feat: observer pattern for statistics
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"git.maximhutz.com/max/lambda/internal/cli"
|
||||
"git.maximhutz.com/max/lambda/internal/config"
|
||||
"git.maximhutz.com/max/lambda/internal/executer"
|
||||
"git.maximhutz.com/max/lambda/internal/profiler"
|
||||
"git.maximhutz.com/max/lambda/internal/statistics"
|
||||
"git.maximhutz.com/max/lambda/pkg/convert"
|
||||
"git.maximhutz.com/max/lambda/pkg/lambda"
|
||||
"git.maximhutz.com/max/lambda/pkg/saccharine"
|
||||
@@ -41,10 +43,21 @@ func main() {
|
||||
logger.Info("compiled lambda expression", "tree", lambda.Stringify(compiled))
|
||||
}
|
||||
|
||||
executor := executer.New(options)
|
||||
results, err := executor.Run(&compiled)
|
||||
process := executer.New(options)
|
||||
if options.Profile != "" {
|
||||
profiler := profiler.New(options.Profile)
|
||||
process.On("start", profiler.Start)
|
||||
process.On("end", profiler.End)
|
||||
}
|
||||
|
||||
statistics := &statistics.Profiler{}
|
||||
process.On("start", statistics.Start)
|
||||
process.On("step", statistics.Step)
|
||||
process.On("end", statistics.End)
|
||||
|
||||
process.Run(&compiled)
|
||||
cli.HandleError(err)
|
||||
|
||||
fmt.Println(lambda.Stringify(compiled))
|
||||
fmt.Fprint(os.Stderr, results.String())
|
||||
fmt.Fprint(os.Stderr, statistics.Results.String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user