summaryrefslogtreecommitdiff
path: root/benches
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 /benches
parent1b3eb42003131c9a5c28ca6efb2c86b43d700016 (diff)
Evaluation benchmark 🔋
Diffstat (limited to 'benches')
-rw-r--r--benches/benchmarks.rs17
1 files changed, 11 insertions, 6 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);