Skip to content

Commit

Permalink
Merge ad2b211 into 3890001
Browse files Browse the repository at this point in the history
  • Loading branch information
zbraniecki committed Jul 27, 2018
2 parents 3890001 + ad2b211 commit 6fbb54e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions intl_pluralrules/benches/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(test)]

extern crate intl_pluralrules;
extern crate test;

use intl_pluralrules::{IntlPluralRules, PluralRuleType};
use test::Bencher;

#[bench]
fn bench_create(b: &mut Bencher) {
b.iter(|| {
IntlPluralRules::create("uk", PluralRuleType::CARDINAL).unwrap();
IntlPluralRules::create("de", PluralRuleType::CARDINAL).unwrap();
IntlPluralRules::create("sk", PluralRuleType::ORDINAL).unwrap();
});
}

#[bench]
fn bench_select(b: &mut Bencher) {
let ipr = IntlPluralRules::create("pl", PluralRuleType::CARDINAL).unwrap();

b.iter(|| {
ipr.select(1).unwrap();
ipr.select(2).unwrap();
ipr.select(5).unwrap();
});
}

#[bench]
fn bench_total(b: &mut Bencher) {
b.iter(|| {
let ipr = IntlPluralRules::create("pl", PluralRuleType::CARDINAL).unwrap();
ipr.select(1).unwrap();
ipr.select(2).unwrap();
ipr.select(3).unwrap();
ipr.select(4).unwrap();
ipr.select(5).unwrap();
ipr.select(5.2).unwrap();
ipr.select(-0.2).unwrap();
ipr.select("12.06").unwrap();
});
}

0 comments on commit 6fbb54e

Please sign in to comment.