Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
sado committed May 10, 2022
1 parent af73319 commit f3d2e6a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 23 additions & 0 deletions kit/rule/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
5 changes: 3 additions & 2 deletions kit/rule/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"go/scanner"
"go/token"
"io"
"log"
"os"
"strings"
Expand All @@ -16,8 +17,8 @@ var (
)

func init() {
//logger.SetFlags(0)
//logger.SetOutput(io.Discard)
logger.SetFlags(0)
logger.SetOutput(io.Discard)
}

type (
Expand Down

0 comments on commit f3d2e6a

Please sign in to comment.