Skip to content

Commit 6a7e38e

Browse files
committed
Refactor Unicode script, emit new tables, and add QuickCheck algorithm.
1 parent 4d76b96 commit 6a7e38e

File tree

10 files changed

+141581
-34659
lines changed

10 files changed

+141581
-34659
lines changed

benches/bench.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,34 @@ extern crate test;
66
use test::Bencher;
77
use unicode_normalization::UnicodeNormalization;
88

9-
macro_rules! bench_check {
10-
($b: ident, $s: expr, $form: ident) => {
11-
let s = $s;
12-
$b.iter(|| s.chars().eq(s.$form()));
13-
}
14-
}
15-
169
#[bench]
1710
fn bench_is_nfc_ascii(b: &mut Bencher) {
18-
bench_check!(b, "all types of normalized", nfc);
11+
b.iter(|| unicode_normalization::is_nfc("all types of normalized"));
1912
}
2013

2114
#[bench]
2215
fn bench_is_nfc_normalized(b: &mut Bencher) {
23-
bench_check!(b, "Introducci\u{00f3}n a Unicode.pdf", nfc);
16+
b.iter(|| unicode_normalization::is_nfc("Introducci\u{00f3}n a Unicode.pdf"));
2417
}
2518

2619
#[bench]
2720
fn bench_is_nfc_not_normalized(b: &mut Bencher) {
28-
bench_check!(b, "Introduccio\u{0301}n a Unicode.pdf", nfc);
21+
b.iter(|| unicode_normalization::is_nfc("Introduccio\u{0301}n a Unicode.pdf"));
2922
}
3023

3124
#[bench]
3225
fn bench_is_nfd_ascii(b: &mut Bencher) {
33-
bench_check!(b, "an easy string to check", nfd);
26+
b.iter(|| unicode_normalization::is_nfd("an easy string to check"));
3427
}
3528

3629
#[bench]
3730
fn bench_is_nfd_normalized(b: &mut Bencher) {
38-
bench_check!(b, "Introduccio\u{0301}n a Unicode.pdf", nfd);
31+
b.iter(|| unicode_normalization::is_nfd("Introduccio\u{0301}n a Unicode.pdf"));
3932
}
4033

4134
#[bench]
4235
fn bench_is_nfd_not_normalized(b: &mut Bencher) {
43-
bench_check!(b, "Introducci\u{00f3}n a Unicode.pdf", nfd);
36+
b.iter(|| unicode_normalization::is_nfd("Introducci\u{00f3}n a Unicode.pdf"));
4437
}
4538

4639
#[bench]

0 commit comments

Comments
 (0)