Files
expr/parser/bench_test.go
Diego Augusto MolinaandGitHub fefc347053 Improve parser and lexer (#811)
* convert source to a struct and fix minor issue displaying error

* lexer: add byte and char pos

* improve parser to use string instead of []rune

* add lexer benchmarks

* make lexer work as an iterator

* make parser use the new iterator API in lexer

* allow reusing the parser

* cleanup code

* add parser benchmarks
2025-06-30 20:08:46 +02:00

21 lines
384 B
Go

package parser
import "testing"
func BenchmarkParser(b *testing.B) {
const source = `
/*
Showing worst case scenario
*/
let value = trim("contains escapes \n\"\\ \U0001F600 and non ASCII ñ"); // inline comment
len(value) == 0x2A
// let's introduce an error too
whatever
`
b.ReportAllocs()
p := new(Parser)
for i := 0; i < b.N; i++ {
p.Parse(source, nil)
}
}