add iai benchmarks
This commit is contained in:
parent
4f0be0c265
commit
a36cb74c66
4 changed files with 51 additions and 0 deletions
14
bench/iai/Cargo.toml
Normal file
14
bench/iai/Cargo.toml
Normal 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
21
bench/iai/main.rs
Normal 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);
|
Loading…
Add table
Add a link
Reference in a new issue