Skip to content

Commit

Permalink
fixup: adds individual sample measurements
Browse files Browse the repository at this point in the history
Helps smoke out specific performance regressions.
  • Loading branch information
filmil committed Oct 1, 2020
1 parent 0e12fd0 commit 98d72b4
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion components/pluralrules/benches/operands.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod fixtures;
mod helpers;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use std::convert::TryInto;

use icu_num_util::FixedDecimal;
Expand Down Expand Up @@ -41,6 +41,28 @@ fn operands(c: &mut Criterion) {
})
});

{
let samples = [
"0",
"10",
"200",
"3000",
"40000",
"500000",
"6000000",
"70000000",
"0012.3400",
"00.0012216734340",
];
let mut group = c.benchmark_group("operands/create/string/samples");
for s in samples.iter() {
group.bench_with_input(BenchmarkId::from_parameter(s), s, |b, s| {
b.iter(|| {
let _: PluralOperands = black_box(s).parse().unwrap();
})
});
}
}
c.bench_function("operands/eq/mostly_unequal", |b| {
let p: PluralOperands = "1".parse().expect("Parse successful");
b.iter(|| {
Expand Down Expand Up @@ -77,6 +99,22 @@ fn operands(c: &mut Criterion) {
}
});
});

{
let samples = [
FixedDecimal::from(1).multiplied_pow10(0).unwrap(),
FixedDecimal::from(123450).multiplied_pow10(-4).unwrap(),
FixedDecimal::from(2500).multiplied_pow10(-2).unwrap(),
];
let mut group = c.benchmark_group("operands/create/from_fixed_decimal/samples");
for s in samples.iter() {
group.bench_with_input(
BenchmarkId::from_parameter(format!("{:?}", &s)),
s,
|b, f| b.iter(|| PluralOperands::from(black_box(f))),
);
}
}
}

criterion_group!(benches, operands,);
Expand Down

0 comments on commit 98d72b4

Please sign in to comment.