diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-22 14:31:09 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-23 14:53:55 +0100 |
| commit | e1f29d6cb9437a4afb2e4fc4ee10a5b8717ab9fa (patch) | |
| tree | 1ce5f2bd858f6665d3867a2939d4b474c1b70377 /benches | |
| parent | 2bf32c51bceb2f3a8b7ebea3d7c7d6d96757591b (diff) | |
Rework the core context
Diffstat (limited to 'benches')
| -rw-r--r-- | benches/oneshot.rs | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/benches/oneshot.rs b/benches/oneshot.rs index 5dbf993f..9bce185c 100644 --- a/benches/oneshot.rs +++ b/benches/oneshot.rs @@ -5,7 +5,7 @@ use iai::{black_box, main, Iai}; use typst::loading::MemLoader; use typst::parse::{parse, Scanner, TokenMode, Tokens}; use typst::source::SourceId; -use typst::{Context, Vm}; +use typst::Context; const SRC: &str = include_str!("bench.typ"); const FONT: &[u8] = include_bytes!("../fonts/IBMPlexSans-Regular.ttf"); @@ -26,7 +26,6 @@ main!( bench_eval, bench_layout, bench_highlight, - bench_byte_to_utf16, bench_render, ); @@ -67,37 +66,21 @@ fn bench_edit(iai: &mut Iai) { iai.run(|| black_box(ctx.sources.edit(id, 1168 .. 1171, "_Uhr_"))); } -fn bench_eval(iai: &mut Iai) { - let (mut ctx, id) = context(); - let mut vm = Vm::new(&mut ctx); - iai.run(|| vm.evaluate(id).unwrap()); -} - -fn bench_layout(iai: &mut Iai) { - let (mut ctx, id) = context(); - let mut vm = Vm::new(&mut ctx); - let module = vm.evaluate(id).unwrap(); - iai.run(|| module.template.layout_pages(&mut vm)); -} - fn bench_highlight(iai: &mut Iai) { let (ctx, id) = context(); let source = ctx.sources.get(id); iai.run(|| source.highlight(0 .. source.len_bytes(), |_, _| {})); } -fn bench_byte_to_utf16(iai: &mut Iai) { - let (ctx, id) = context(); - let source = ctx.sources.get(id); - let mut ranges = vec![]; - source.highlight(0 .. source.len_bytes(), |range, _| ranges.push(range)); - iai.run(|| { - ranges - .iter() - .map(|range| source.byte_to_utf16(range.start) - .. source.byte_to_utf16(range.end)) - .collect::<Vec<_>>() - }); +fn bench_eval(iai: &mut Iai) { + let (mut ctx, id) = context(); + iai.run(|| ctx.evaluate(id).unwrap()); +} + +fn bench_layout(iai: &mut Iai) { + let (mut ctx, id) = context(); + let module = ctx.evaluate(id).unwrap(); + iai.run(|| module.template.layout(&mut ctx)); } fn bench_render(iai: &mut Iai) { |
