diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-11-25 19:28:04 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-11-25 19:28:04 +0100 |
| commit | b4f809f1ea8a469d0bdee225f47d7f09bc22aa61 (patch) | |
| tree | 93a186e98a278588b42d61fdbe814151f3e6fce7 /benches | |
| parent | e30d896c7b871b1588925cadd10808c65e93d511 (diff) | |
Move benchmarks into separate crate ♾
So that CI does not have to build criterion each time.
Diffstat (limited to 'benches')
| -rw-r--r-- | benches/benchmarks.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs deleted file mode 100644 index ea37ff0f..00000000 --- a/benches/benchmarks.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::cell::RefCell; -use std::rc::Rc; - -use criterion::{criterion_group, criterion_main, Criterion}; -use fontdock::fs::{FsIndex, FsSource}; - -use typst::eval::{eval, State}; -use typst::font::FontLoader; -use typst::layout::layout; -use typst::parse::parse; -use typst::typeset; - -const FONT_DIR: &str = "fonts"; -const COMA: &str = include_str!("../tests/typ/coma.typ"); - -fn benchmarks(c: &mut Criterion) { - let state = State::default(); - - let mut index = FsIndex::new(); - index.search_dir(FONT_DIR); - - let (files, descriptors) = index.into_vecs(); - let loader = Rc::new(RefCell::new(FontLoader::new( - Box::new(FsSource::new(files)), - descriptors, - ))); - - let tree = parse(COMA).output; - let document = eval(&tree, state.clone()).output; - let _ = layout(&document, Rc::clone(&loader)); - - c.bench_function("parse-coma", |b| b.iter(|| parse(COMA))); - c.bench_function("eval-coma", |b| b.iter(|| eval(&tree, state.clone()))); - c.bench_function("layout-coma", |b| { - b.iter(|| layout(&document, Rc::clone(&loader))) - }); - c.bench_function("typeset-coma", |b| { - b.iter(|| typeset(COMA, state.clone(), Rc::clone(&loader))) - }); -} - -criterion_group!(benches, benchmarks); -criterion_main!(benches); |
