chore: update benchmark
This commit is contained in:
parent
471a23c958
commit
be32dc24e0
3 changed files with 26 additions and 9 deletions
|
|
@ -1,24 +1,39 @@
|
|||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
||||
|
||||
use orgize::Org;
|
||||
|
||||
const INPUT: &[(&str, &str)] = &[
|
||||
("doc.org", include_str!("./doc.org")),
|
||||
("org-faq.org", include_str!("./org-faq.org")),
|
||||
("org-hacks.org", include_str!("./org-hacks.org")),
|
||||
(
|
||||
"org-release-notes.org",
|
||||
include_str!("./org-release-notes.org"),
|
||||
),
|
||||
("org-syntax.org", include_str!("./org-syntax.org")),
|
||||
];
|
||||
|
||||
pub fn bench_parse(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("Parse");
|
||||
let mut group = c.benchmark_group("Org::parse");
|
||||
|
||||
for (id, json) in INPUT.iter() {
|
||||
group.bench_with_input(BenchmarkId::new("Rowan", id), json, |b, i| {
|
||||
b.iter(|| Org::parse(i))
|
||||
});
|
||||
for (id, org) in INPUT {
|
||||
group.throughput(Throughput::Bytes(org.len() as u64));
|
||||
group.bench_with_input(*id, org, |b, i| b.iter(|| Org::parse(i)));
|
||||
}
|
||||
|
||||
group.finish();
|
||||
}
|
||||
|
||||
criterion_group!(benches, bench_parse);
|
||||
pub fn bench_to_html(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("Org::to_html");
|
||||
|
||||
for (id, org) in INPUT {
|
||||
group.throughput(Throughput::Bytes(org.len() as u64));
|
||||
group.bench_with_input(*id, &Org::parse(org), |b, i| b.iter(|| i.to_html()));
|
||||
}
|
||||
|
||||
group.finish();
|
||||
}
|
||||
|
||||
criterion_group!(benches, bench_parse, bench_to_html);
|
||||
criterion_main!(benches);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ cargo fuzz run fuzz_target_1
|
|||
```shell
|
||||
curl -q https://orgmode.org/worg/doc.org --output ./benches/doc.org
|
||||
curl -q https://orgmode.org/worg/org-faq.org --output ./benches/org-faq.org
|
||||
curl -q https://orgmode.org/worg/org-hacks.org --output ./benches/org-hacks.org
|
||||
curl -q https://orgmode.org/worg/org-release-notes.org --output ./benches/org-release-notes.org
|
||||
curl -q https://orgmode.org/worg/org-syntax.org --output ./benches/org-syntax.org
|
||||
|
||||
cargo bench --bench parse
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ fn main() {
|
|||
if args.len() < 2 {
|
||||
eprintln!("Usage: {} <org-mode-string>", args[0]);
|
||||
} else {
|
||||
let s = &args[1].replace(r#"\n"#, "\n").replace(r#"\r"#, "\r");
|
||||
let org = Org::parse(&s);
|
||||
let s = &args[1].replace(r"\n", "\n").replace(r"\r", "\r");
|
||||
let org = Org::parse(s);
|
||||
println!("{:#?}", org.document().syntax());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue