summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-11 23:18:00 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-11 23:18:00 +0200
commita2a68106c025ada726e291df4d7e5aa624f68410 (patch)
treed06c34c72414c9c85b376ab9b5e907294f8ac68b
parent1b3eb42003131c9a5c28ca6efb2c86b43d700016 (diff)
Evaluation benchmark 🔋
-rw-r--r--benches/benchmarks.rs17
-rw-r--r--src/layout/par.rs2
-rw-r--r--src/layout/stack.rs2
3 files changed, 13 insertions, 8 deletions
diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs
index 3ffee01e..010862ac 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 8c44e0f4..729c077f 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<Dir>,
- /// How to align _this_ paragraph in _its_ parent.
+ /// How to align this paragraph in _its_ parent.
pub aligns: Gen<Align>,
/// 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 6ff287f0..2f3ceed8 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<Dir>,
- /// How to align _this_ stack in _its_ parent.
+ /// How to align this stack in _its_ parent.
pub aligns: Gen<Align>,
/// Whether to expand the axes to fill the area or to fit the content.
pub expansion: Gen<Expansion>,