Skip to content

Commit e2111b8

Browse files
committed
add parser benchmarks
1 parent af94f4b commit e2111b8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

parser/bench_test.go

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

0 commit comments

Comments
 (0)