From 1f9433d9f591b8a6193f215113b97e174b850e62 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 18 Jul 2022 18:57:08 +0200 Subject: Add a benchmark --- benches/bench.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 benches/bench.rs (limited to 'benches') diff --git a/benches/bench.rs b/benches/bench.rs new file mode 100644 index 0000000..2d0875e --- /dev/null +++ b/benches/bench.rs @@ -0,0 +1,28 @@ +#[macro_use] +extern crate criterion; +use criterion::{BenchmarkId, Criterion}; +use micromark::micromark; +use std::fs; + +fn readme(c: &mut Criterion) { + let doc = fs::read_to_string("readme.md").unwrap(); + + c.bench_with_input(BenchmarkId::new("readme", "readme"), &doc, |b, s| { + b.iter(|| micromark(s)); + }); +} + +// fn one_and_a_half_mb(c: &mut Criterion) { +// let doc = fs::read_to_string("../a-dump-of-markdown/markdown.md").unwrap(); +// let mut group = c.benchmark_group("giant"); +// group.sample_size(10); +// group.bench_with_input(BenchmarkId::new("giant", "1.5 mb"), &doc, |b, s| { +// b.iter(|| micromark(s)); +// }); +// group.finish(); +// } + +// one_and_a_half_mb + +criterion_group!(benches, readme); +criterion_main!(benches); -- cgit