<commit_before>#![feature(test)]

#[macro_use]
extern crate lazy_static;
extern crate test;

use std::path::PathBuf;
use test::Bencher;

extern crate hyphenation;
use hyphenation::{load, Language};
use hyphenation::exception::{Exceptions};
use hyphenation::pattern::{Patterns};


lazy_static! {
    static ref DATAPATH: PathBuf = {
        let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
        path.push("patterns");

        path
    };
}


#[bench]
fn parse_patterns_en_us(bench: &mut Bencher) {
    hyphenation::set_pattern_folder(DATAPATH.as_path());

    let by_line = load::patterns(Language::English_US).unwrap();
    let v: Vec<_> = by_line.collect();

    let mut ps = Patterns::empty();
    bench.iter(|| {
        for p in &v {
            for val in p { ps.insert(&*val) };
        }
    });
}

#[bench]
fn parse_exceptions_en_us(bench: &mut Bencher) {
    hyphenation::set_pattern_folder(DATAPATH.as_path());

    let by_line = load::exceptions(Language::English_US).unwrap();
    let v: Vec<_> = by_line.collect();

    let mut exs = Exceptions::empty();
    bench.iter(|| {
        for ex in &v {
            for val in ex { exs.insert(&*val) };
        }
    });
}
<commit_msg>Trivial renames<commit_after>#![feature(test)]

#[macro_use]
extern crate lazy_static;
extern crate test;

use std::path::PathBuf;
use test::Bencher;

extern crate hyphenation;
use hyphenation::{load, Language};
use hyphenation::exception::{Exceptions};
use hyphenation::pattern::{Patterns};


lazy_static! {
    static ref DATAPATH: PathBuf = {
        let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
        path.push("patterns");

        path
    };
}


#[bench]
fn parse_patterns_en_us(b: &mut Bencher) {
    hyphenation::set_pattern_folder(DATAPATH.as_path());

    let by_line = load::patterns(Language::English_US).unwrap();
    let v: Vec<_> = by_line.collect();

    let mut ps = Patterns::empty();
    b.iter(|| {
        for p in &v {
            for val in p { ps.insert(&*val) };
        }
    });
}

#[bench]
fn parse_exceptions_en_us(b: &mut Bencher) {
    hyphenation::set_pattern_folder(DATAPATH.as_path());

    let by_line = load::exceptions(Language::English_US).unwrap();
    let v: Vec<_> = by_line.collect();

    let mut exs = Exceptions::empty();
    b.iter(|| {
        for ex in &v {
            for val in ex { exs.insert(&*val) };
        }
    });
}

{'fraction_non_alphanumeric': 0.15859766277128548, 'fraction_numerical': 0.0, 'mean_word_length': 3.342391304347826, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '294007', 'n_tokens_mistral': 854, 'n_tokens_neox': 847, 'n_words': 175}