Skip to content

Commit

Permalink
fix bench
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed May 5, 2024
1 parent 9b5e11c commit 31c323a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
31 changes: 3 additions & 28 deletions benchmarks/benches/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,11 @@ fn json_bench(c: &mut Criterion) {
static CANADA: &str = include_str!("../canada.json");
fn canada_json(c: &mut Criterion) {
// test once to make sure it parses correctly
json::<Error<&str>>(CANADA).unwrap();
json(CANADA).unwrap();

// println!("data:\n{:?}", json(data));
c.bench_function("json canada", |b| {
b.iter(|| json::<Error<&str>>(CANADA).unwrap());
});
}

fn verbose_json(c: &mut Criterion) {
let data = " { \"a\"\t: 42,
\"b\": [ \"x\", \"y\", 12 ,\"\\u2014\", \"\\uD83D\\uDE10\"] ,
\"c\": { \"hello\" : \"world\"
}
} ";

// test once to make sure it parses correctly
json::<VerboseError<&str>>(data).unwrap();

// println!("data:\n{:?}", json(data));
c.bench_function("json verbose", |b| {
b.iter(|| json::<VerboseError<&str>>(data).unwrap());
});
}

fn verbose_canada_json(c: &mut Criterion) {
// test once to make sure it parses correctly
json::<VerboseError<&str>>(CANADA).unwrap();

// println!("data:\n{:?}", json(data));
c.bench_function("json canada verbose", |b| {
b.iter(|| json::<VerboseError<&str>>(CANADA).unwrap());
b.iter(|| json(CANADA).unwrap());
});
}

Expand Down Expand Up @@ -250,6 +224,7 @@ fn std_float_bytes(c: &mut Criterion) {
criterion_group!(
benches,
json_bench,
canada_json,
recognize_float_bytes,
recognize_float_str,
float_bytes,
Expand Down
9 changes: 9 additions & 0 deletions benchmarks/canada.json

Large diffs are not rendered by default.

0 comments on commit 31c323a

Please sign in to comment.