Skip to content

Commit 436b8ae

Browse files
committed
add lexer benchmarks
1 parent 89f608f commit 436b8ae

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

parser/lexer/bench_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package lexer
2+
3+
import (
4+
"testing"
5+
6+
"github.com/expr-lang/expr/file"
7+
)
8+
9+
func BenchmarkParser(b *testing.B) {
10+
const source = `
11+
/*
12+
Showing worst case scenario
13+
*/
14+
let value = trim("contains escapes \n\"\\ \U0001F600 and non ASCII ñ"); // inline comment
15+
len(value) == 0x2A
16+
// let's introduce an error too
17+
whatever
18+
`
19+
b.ReportAllocs()
20+
for i := 0; i < b.N; i++ {
21+
Lex(file.NewSource(source))
22+
}
23+
}

0 commit comments

Comments
 (0)