Skip to content

Commit

Permalink
fix bench
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Oct 1, 2024
1 parent 5ae736c commit 79b5f5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
11 changes: 5 additions & 6 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ extern crate test;

#[cfg(test)]
mod tests {
use test::Bencher;
use wana_kana::{to_kana, to_romaji, *};
use wana_kana::*;

#[bench]
fn bench_kana_1(b: &mut test::Bencher) {
b.iter(|| to_kana::to_kana("aiueosashisusesonaninunenokakikukeko"))
b.iter(|| "aiueosashisusesonaninunenokakikukeko".to_kana())
}

#[bench]
fn bench_kana_2(b: &mut test::Bencher) {
b.iter(|| to_kana::to_kana("AIUEOSASHISUSESONANINUNENOKAKIKUKEKO"))
b.iter(|| "AIUEOSASHISUSESONANINUNENOKAKIKUKEKO".to_kana())
}

#[bench]
Expand All @@ -39,11 +38,11 @@ mod tests {

#[bench]
fn bench_hiragana_to_romaji(b: &mut test::Bencher) {
b.iter(|| to_romaji::to_romaji("あいうえおさしすせそなにぬねのかきくけこ"))
b.iter(|| "あいうえおさしすせそなにぬねのかきくけこ".to_romaji())
}

#[bench]
fn bench_katakana_to_romaji(b: &mut test::Bencher) {
b.iter(|| to_romaji::to_romaji("アイウエオサシスセソナニヌネノカキクケコ"))
b.iter(|| "アイウエオサシスセソナニヌネノカキクケコ".to_romaji())
}
}
16 changes: 4 additions & 12 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ mod tests {

#[test]
fn is_char_english_punctuation_test() {
assert!(
EN_PUNC.iter().cloned().all(is_char_english_punctuation)
);
assert!(
!JA_PUNC.iter().cloned().all(is_char_english_punctuation)
);
assert!(EN_PUNC.iter().cloned().all(is_char_english_punctuation));
assert!(!JA_PUNC.iter().cloned().all(is_char_english_punctuation));
assert!(is_char_english_punctuation(' '));
assert!(!is_char_english_punctuation('a'));
assert!(!is_char_english_punctuation('ふ'));
Expand All @@ -84,12 +80,8 @@ mod tests {

#[test]
fn is_char_japanese_punctuation_test() {
assert!(
!EN_PUNC.iter().cloned().all(is_char_japanese_punctuation)
);
assert!(
JA_PUNC.iter().cloned().all(is_char_japanese_punctuation)
);
assert!(!EN_PUNC.iter().cloned().all(is_char_japanese_punctuation));
assert!(JA_PUNC.iter().cloned().all(is_char_japanese_punctuation));
assert!(is_char_japanese_punctuation(' '));
assert!(!is_char_japanese_punctuation('?'));
assert!(!is_char_japanese_punctuation('a'));
Expand Down
4 changes: 1 addition & 3 deletions tests/is_japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ mod tests {
}
#[test]
fn kanji_with_zenkaku_punctuation_is_japanese() {
assert!(
"泣き虫。#!〜〈〉《》〔〕[]【】(){}〝〟".is_japanese()
);
assert!("泣き虫。#!〜〈〉《》〔〕[]【】(){}〝〟".is_japanese());
}
#[test]
fn kanji_with_romaji_punctuation_is_not_japanese() {
Expand Down

0 comments on commit 79b5f5a

Please sign in to comment.