add iai benchmarks

This commit is contained in:
Noah Hellman 2023-02-12 13:31:14 +01:00
parent 4f0be0c265
commit a36cb74c66
4 changed files with 51 additions and 0 deletions

14
bench/iai/Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "bench-iai"
version = "0.1.0"
edition = "2021"
[dev-dependencies]
iai = { version = "0.1", default-features = false }
bench-input = { path = "../input" }
jotdown = { path = "../../", features = ["html", "deterministic"] }
[[bench]]
name = "iai"
path = "main.rs"
harness = false

21
bench/iai/main.rs Normal file
View file

@ -0,0 +1,21 @@
use iai::black_box;
use jotdown::Render;
fn block() -> jotdown::Parser<'static> {
jotdown::Parser::new(black_box(bench_input::ALL))
}
fn block_inline() -> Option<jotdown::Event<'static>> {
black_box(jotdown::Parser::new(black_box(bench_input::ALL))).last()
}
fn full() -> String {
let mut s = String::new();
jotdown::html::Renderer
.push(jotdown::Parser::new(bench_input::ALL), &mut s)
.unwrap();
s
}
iai::main!(block, block_inline, full);