Add basic parsing benchmark 🌩
This commit is contained in:
parent
691423a40a
commit
0ac2e86feb
@ -23,12 +23,18 @@ serialize = []
|
||||
fs = ["fontdock/fs"]
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
futures-executor = "0.3"
|
||||
serde_json = "1"
|
||||
raqote = { version = "0.8", default-features = false }
|
||||
|
||||
[[test]]
|
||||
name = "test-typeset"
|
||||
name = "typeset"
|
||||
path = "tests/test_typeset.rs"
|
||||
required-features = ["fs"]
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "bench-parsing"
|
||||
path = "benches/bench_parsing.rs"
|
||||
harness = false
|
||||
|
24
benches/bench_parsing.rs
Normal file
24
benches/bench_parsing.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use typstc::library::_std;
|
||||
use typstc::syntax::parsing::{parse, ParseState};
|
||||
use typstc::syntax::span::Pos;
|
||||
|
||||
// 28 not too dense lines.
|
||||
const COMA: &str = include_str!("../tests/coma.typ");
|
||||
|
||||
fn parsing_benchmark(c: &mut Criterion) {
|
||||
let state = ParseState { scope: _std() };
|
||||
|
||||
c.bench_function("parse-coma-28-lines", |b| {
|
||||
b.iter(|| parse(COMA, Pos::ZERO, &state))
|
||||
});
|
||||
|
||||
// 2800 lines of Typst code.
|
||||
let long = COMA.repeat(100);
|
||||
c.bench_function("parse-coma-2800-lines", |b| {
|
||||
b.iter(|| parse(&long, Pos::ZERO, &state))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, parsing_benchmark);
|
||||
criterion_main!(benches);
|
Loading…
x
Reference in New Issue
Block a user