-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
} |