<commit_before>#![feature(test)]

extern crate test;
extern crate bf;

use bf::ast;
use bf::rle;
use bf::peephole;
use bf::traits::Interpretable;
use bf::test_helpers;

use test::Bencher;

#[bench]
fn compile_factor(b: &mut Bencher) {
    let program = ast::parse_program(test_helpers::FACTOR_SRC).unwrap();

    b.iter(|| {
        let program = rle::compile(&program);
        peephole::compile(&program)
    });
}

#[bench]
fn interpret_factor_million(b: &mut Bencher) {
    let program = ast::parse_program(test_helpers::FACTOR_SRC).unwrap();
    let program = rle::compile(&program);
    let program = peephole::compile(&program);<commit_msg>Using compilation trait for one benchmark. Worth it?<commit_after>#![feature(test)]

extern crate test;
extern crate bf;

use bf::ast;
use bf::rle;
use bf::peephole::PeepholeCompilable;
use bf::traits::Interpretable;
use bf::test_helpers;

use test::Bencher;

#[bench]
fn compile_factor(b: &mut Bencher) {
    let program = ast::parse_program(test_helpers::FACTOR_SRC).unwrap();

    b.iter(|| {
        let program = rle::compile(&program);
        program.peephole_compile()
    });
}

#[bench]
fn interpret_factor_million(b: &mut Bencher) {
    let program = ast::parse_program(test_helpers::FACTOR_SRC).unwrap();
    let program = program.peephole_compile();
{'fraction_non_alphanumeric': 0.15355233002291827, 'fraction_numerical': 0.0, 'mean_word_length': 5.208530805687204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4771106', 'n_tokens_mistral': 463, 'n_tokens_neox': 472, 'n_words': 95}