diff --git a/kit/rule/benchmark_test.go b/kit/rule/benchmark_test.go new file mode 100644 index 0000000..e912332 --- /dev/null +++ b/kit/rule/benchmark_test.go @@ -0,0 +1,23 @@ +package rule + +import ( + "context" + "testing" +) + +func Benchmark_SingleParse(bench *testing.B) { + + for i := 0; i < bench.N; i++ { + New(context.Background(), "1") + } +} + +func Benchmark_Single(bench *testing.B) { + + parser, _ := New(context.Background(), "1") + + bench.ResetTimer() + for i := 0; i < bench.N; i++ { + parser.Eval(nil) + } +} diff --git a/kit/rule/parser.go b/kit/rule/parser.go index f0edd94..6e4d562 100644 --- a/kit/rule/parser.go +++ b/kit/rule/parser.go @@ -5,6 +5,7 @@ import ( "fmt" "go/scanner" "go/token" + "io" "log" "os" "strings" @@ -16,8 +17,8 @@ var ( ) func init() { - //logger.SetFlags(0) - //logger.SetOutput(io.Discard) + logger.SetFlags(0) + logger.SetOutput(io.Discard) } type (