Skip to content

Commit

Permalink
update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jan 15, 2023
1 parent 31936ee commit 51c4e03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
19 changes: 8 additions & 11 deletions benchmarks/benches/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ fn key_value(i: &[u8]) -> IResult<&[u8], (&str, &str)> {
}

fn categories(i: &[u8]) -> IResult<&[u8], HashMap<&str, HashMap<&str, &str>>> {
map(
many(
0..,
separated_pair(
category,
opt(multispace),
map(
many(0.., terminated(key_value, opt(multispace))),
|vec: Vec<_>| vec.into_iter().collect(),
),
many(
0..,
separated_pair(
category,
opt(multispace),
map(
many(0.., terminated(key_value, opt(multispace))),
|vec: Vec<_>| vec.into_iter().collect(),
),
),
|vec: Vec<_>| vec.into_iter().collect(),
)(i)
}

Expand Down
18 changes: 2 additions & 16 deletions benchmarks/benches/ini_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,16 @@ fn key_value(i: &str) -> IResult<&str, (&str, &str)> {
Ok((i, (key, val)))
}

fn keys_and_values_aggregator(i: &str) -> IResult<&str, Vec<(&str, &str)>> {
many(0.., key_value)(i)
}

fn keys_and_values(input: &str) -> IResult<&str, HashMap<&str, &str>> {
match keys_and_values_aggregator(input) {
Ok((i, tuple_vec)) => Ok((i, tuple_vec.into_iter().collect())),
Err(e) => Err(e),
}
many(0.., key_value)(input)
}

fn category_and_keys(i: &str) -> IResult<&str, (&str, HashMap<&str, &str>)> {
pair(category, keys_and_values)(i)
}

fn categories_aggregator(i: &str) -> IResult<&str, Vec<(&str, HashMap<&str, &str>)>> {
many(0.., category_and_keys)(i)
}

fn categories(input: &str) -> IResult<&str, HashMap<&str, HashMap<&str, &str>>> {
match categories_aggregator(input) {
Ok((i, tuple_vec)) => Ok((i, tuple_vec.into_iter().collect())),
Err(e) => Err(e),
}
many(0.., category_and_keys)(input)
}

fn bench_ini_str(c: &mut Criterion) {
Expand Down

0 comments on commit 51c4e03

Please sign in to comment.