- Significantly improved time to render full document

- Added support for debugging with tokio-console through tracing feature
- Added extra benchmark for checking time to render first page
- Removed unwraps to just make background loops return and terminate if something goes wrong
- Modularize rendering somewhat
This commit is contained in:
itsjunetime
2024-06-04 15:46:25 -06:00
parent a86730b8da
commit 5825849434
8 changed files with 846 additions and 133 deletions
+32 -21
View File
@@ -1,34 +1,45 @@
mod utils;
use utils::render_doc;
use utils::{render_doc, render_first_page};
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
fn render_dict(c: &mut Criterion) {
c.bench_function(
"example dictionary",
|b| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_doc("./benches/example_dictionary.pdf"))
)
);
const FILES: [&str; 2] = [
"./benches/example_dictionary.pdf",
"./benches/adobe_example.pdf"
];
fn render_full(c: &mut Criterion) {
for file in FILES {
c.bench_with_input(
BenchmarkId::new("render_full", file),
&file,
|b, &file| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_doc(file))
)
);
}
}
fn render_example(c: &mut Criterion) {
c.bench_function(
"adobe-provided sample",
|b| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_doc("./benches/adobe_example.pdf"))
)
);
fn render_to_first_page(c: &mut Criterion) {
for file in FILES {
c.bench_with_input(
BenchmarkId::new("render_first_page", file),
&file,
|b, &file| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_first_page(file))
)
);
}
}
criterion_group!(
name = benches;
config = Criterion::default().sample_size(10);
targets = render_dict, render_example
targets = render_full, render_to_first_page
);
criterion_main!(benches);