use criterion::{black_box, criterion_group, criterion_main, Criterion}; use html_pipe::*; use std::fmt::Write; fn render_hello_world(name: &str) -> String { let mut buffer = Buffer::with_capacity(200); buffer.push_str(DOCTYPE); node( "html", attr("lang", "en"), node("body", noop, |buf| { write!(buf, "Hello World {name}!")?; Ok(buf) }), )(&mut buffer) .unwrap(); buffer } fn criterion_benchmark(c: &mut Criterion) { c.bench_function("hello world", |b| { b.iter(|| render_hello_world(black_box("Jeremie"))) }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);