diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-18 18:57:08 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-18 18:57:08 +0200 |
commit | 1f9433d9f591b8a6193f215113b97e174b850e62 (patch) | |
tree | 2b7f1308662568e0ec5fab1115a00148232e9e86 | |
parent | d2a7c1fb0344971ac537e15d1a4b00fe18ff8c43 (diff) | |
download | markdown-rs-1f9433d9f591b8a6193f215113b97e174b850e62.tar.gz markdown-rs-1f9433d9f591b8a6193f215113b97e174b850e62.tar.bz2 markdown-rs-1f9433d9f591b8a6193f215113b97e174b850e62.zip |
Add a benchmark
-rw-r--r-- | Cargo.toml | 7 | ||||
-rw-r--r-- | benches/bench.rs | 28 |
2 files changed, 35 insertions, 0 deletions
@@ -13,10 +13,17 @@ categories = ["compilers", "encoding", "parser-implementations", "parsing", "tex include = ["src/", "license"] publish = false +[[bench]] +name = "bench" +harness = false + [dependencies] env_logger = "0.9" log = "0.4" +[dev-dependencies] +criterion = "0.3" + [build-dependencies] regex = "1.5" reqwest = "0.11" 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); |