mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
- In addition to syntax trees there are now `Value`s, which syntax trees can be evaluated into (e.g. the tree is `5+5` and the value is `10`) - Parsing is completely pure, function calls are not parsed into nodes, but into simple call expressions, which are resolved later - Functions aren't dynamic nodes anymore, but simply functions which receive their arguments as a table and the layouting context - Functions may return any `Value` - Layouting is powered by functions which return the new `Commands` value, which informs the layouting engine what to do - When a function returns a non-`Commands` value, the layouter simply dumps the value into the document in monospace
21 lines
565 B
Rust
21 lines
565 B
Rust
use criterion::{criterion_group, criterion_main, Criterion};
|
|
use typstc::syntax::parsing::parse;
|
|
use typstc::syntax::span::Pos;
|
|
|
|
// 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, Pos::ZERO))
|
|
});
|
|
|
|
let long = COMA.repeat(100);
|
|
c.bench_function("parse-coma-2800-lines", |b| {
|
|
b.iter(|| parse(&long, Pos::ZERO))
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, parsing_benchmark);
|
|
criterion_main!(benches);
|