Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
j5ik2o committed Dec 24, 2023
1 parent 5c340a0 commit 6369b87
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
40 changes: 22 additions & 18 deletions parser/benches/bench_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,38 @@ mod nom_json;
mod oni_comb_json;
mod pom_json;

fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("json");
fn criterion_benchmark(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("json");
// let data = r#"{ "a" : 42, "b" : [ "x", "y", 12 ], "c": { "hello" : "world" } }"#;
let data = r#"true"#;

group.bench_with_input(BenchmarkId::new("nom", "bool"), data, |b, i| {
b.iter(|| nom_parse_json(i))
});
group.bench_with_input(BenchmarkId::new("pom", "bool"), data, |b, i| {
b.iter(|| pom_parse_json(i))
});
group.bench_with_input(BenchmarkId::new("oni-comb-rs", "bool"), data, |b, i| {
b.iter(|| oni_comb_parse_json(i))
group.bench_function(BenchmarkId::new("oni-comb-rs", "bool"), |b| {
b.iter(|| oni_comb_parse_json(data))
});

// group.bench_with_input(BenchmarkId::new("nom", "bool"), data, |b, i| {
// b.iter(|| nom_parse_json(i))
// });
// group.bench_with_input(BenchmarkId::new("pom", "bool"), data, |b, i| {
// b.iter(|| pom_parse_json(i))
// });
// group.bench_with_input(BenchmarkId::new("oni-comb-rs", "bool"), data, |b, i| {
// b.iter(|| oni_comb_parse_json(i))
// });
group.finish();
}

// criterion_group! {
// name = benches;
// config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
// targets = criterion_benchmark
// }

criterion_group! {
benches,
criterion_benchmark
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}

// criterion_group! {
// benches,
// criterion_benchmark
// }

criterion_main! {
benches,
}
6 changes: 5 additions & 1 deletion run-benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env sh

cargo bench -p oni-comb-parser-rs
# cargo bench -p oni-comb-parser-rs

pushd parser
cargo bench -- --profile-time 60
popd

0 comments on commit 6369b87

Please sign in to comment.