typst/benches/bench_parsing.rs
Laurenz 3cbca56a71 Parse braced expressions and bracketed calls in headers 🗳
- Refactors the tokenizer to be lazy: It does not emit pre-parsed function tokens, but instead allows it's mode to be changed. The modes are tracked on a stack to allow nested compute/typesetting (pop/push).
- Introduces delimited groups into the parser, which make it easy to parse delimited expressions without handling the delimiters in the parsing code for the group's content. A group is started with `start_group`. When reaching the group's end (matching delimiter) the eat and peek methods will simply return `None` instead of the delimiter, stopping the content parser and bubbling up the call stack until `end_group` is called to clear up the situation.
2020-08-17 16:25:09 +02:00

20 lines
512 B
Rust

use criterion::{criterion_group, criterion_main, Criterion};
use typstc::syntax::parsing::parse;
// 28 not too dense lines.
const COMA: &str = include_str!("../tests/coma.typ");
fn parsing_benchmark(c: &mut Criterion) {
c.bench_function("parse-coma-28-lines", |b| {
b.iter(|| parse(COMA))
});
let long = COMA.repeat(100);
c.bench_function("parse-coma-2800-lines", |b| {
b.iter(|| parse(&long))
});
}
criterion_group!(benches, parsing_benchmark);
criterion_main!(benches);