add iai benchmarks
This commit is contained in:
parent
4f0be0c265
commit
a36cb74c66
4 changed files with 51 additions and 0 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -34,6 +34,15 @@ dependencies = [
|
|||
"jotdown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bench-iai"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bench-input",
|
||||
"iai",
|
||||
"jotdown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bench-input"
|
||||
version = "0.1.0"
|
||||
|
@ -171,6 +180,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iai"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71a816c97c42258aa5834d07590b718b4c9a598944cd39a52dc25b351185d678"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.2"
|
||||
|
|
|
@ -20,6 +20,7 @@ exclude = [
|
|||
[workspace]
|
||||
members = [
|
||||
"bench/criterion",
|
||||
"bench/iai",
|
||||
"bench/input",
|
||||
"examples/jotdown_wasm",
|
||||
]
|
||||
|
|
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…
Reference in a new issue