mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Evaluation benchmark 🔋
This commit is contained in:
parent
1b3eb42003
commit
a2a68106c0
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user