diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs index 3ffee01ef..010862ac0 100644 --- a/benches/benchmarks.rs +++ b/benches/benchmarks.rs @@ -3,9 +3,8 @@ use std::rc::Rc; use criterion::{criterion_group, criterion_main, Criterion}; use fontdock::fs::{FsIndex, FsProvider}; -use futures_executor::block_on; -use typstc::eval::State; +use typstc::eval::{eval, State}; use typstc::font::FontLoader; use typstc::parse::parse; use typstc::typeset; @@ -13,11 +12,17 @@ use typstc::typeset; const FONT_DIR: &str = "fonts"; const COMA: &str = include_str!("../tests/coma.typ"); -fn parsing_benchmark(c: &mut Criterion) { +fn parse_benchmark(c: &mut Criterion) { c.bench_function("parse-coma", |b| b.iter(|| parse(COMA))); } -fn typesetting_benchmark(c: &mut Criterion) { +fn eval_benchmark(c: &mut Criterion) { + let tree = parse(COMA).output; + let state = State::default(); + c.bench_function("eval-coma", |b| b.iter(|| eval(&tree, state.clone()))); +} + +fn typeset_benchmark(c: &mut Criterion) { let mut index = FsIndex::new(); index.search_dir(FONT_DIR); @@ -28,9 +33,9 @@ fn typesetting_benchmark(c: &mut Criterion) { let state = State::default(); c.bench_function("typeset-coma", |b| { - b.iter(|| block_on(typeset(COMA, state.clone(), Rc::clone(&loader)))) + b.iter(|| typeset(COMA, state.clone(), Rc::clone(&loader))) }); } -criterion_group!(benches, parsing_benchmark, typesetting_benchmark); +criterion_group!(benches, parse_benchmark, eval_benchmark, typeset_benchmark); criterion_main!(benches); diff --git a/src/layout/par.rs b/src/layout/par.rs index 8c44e0f4e..729c077fa 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -8,7 +8,7 @@ pub struct Par { /// The children are placed in lines along the `cross` direction. The lines /// are stacked along the `main` direction. pub dirs: Gen, - /// How to align _this_ paragraph in _its_ parent. + /// How to align this paragraph in _its_ parent. pub aligns: Gen, /// Whether to expand the cross axis to fill the area or to fit the content. pub cross_expansion: Expansion, diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 6ff287f08..2f3ceed80 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -8,7 +8,7 @@ pub struct Stack { /// The children are stacked along the `main` direction. The `cross` /// direction is required for aligning the children. pub dirs: Gen, - /// How to align _this_ stack in _its_ parent. + /// How to align this stack in _its_ parent. pub aligns: Gen, /// Whether to expand the axes to fill the area or to fit the content. pub expansion: Gen,