#![feature(test)]

extern crate test;
extern crate bio;

use test::Bencher;
use bio::pattern_matching::shift_and::ShiftAnd;
use bio::pattern_matching::bndm::BNDM;
use bio::pattern_matching::kmp::KMP;
use bio::pattern_matching::bom::BOM;
use bio::pattern_matching::horspool::Horspool;

static TEXT: &'static [u8] = b"[encoded data, 16569 characters]";
static PATTERN: &'static [u8] = b"GCGCGTACACACCGCCCG";

#[bench]
fn bench_shift_and(b: &mut Bencher) {
    b.iter(|| {
        for _ in 0..10000 {
            let shiftand = ShiftAnd::new(PATTERN);
            shiftand.find_all(TEXT.iter()).collect::<Vec<usize>>();
        }
    });
}

#[bench]
fn bench_bndm(b: &mut Bencher) {
    b.iter(|| {
        for _ in 0..10000 {
            let bndm = BNDM::new(PATTERN);
            bndm.find_all(TEXT).collect::<Vec<usize>>();
        }
    });
}

#[bench]
fn bench_bom(b: &mut Bencher) {
    b.iter(|| {
        for _ in 0..10000 {
            let bom = BOM::new(PATTERN);
            bom.find_all(TEXT).collect::<Vec<usize>>();
        }
    });
}

#[bench]
fn bench_horspool(b: &mut Bencher) {
    b.iter(|| {
        for _ in 0..10000 {
            let horspool = Horspool::new(PATTERN);
            horspool.find_all(TEXT).collect::<Vec<usize>>();
        }
    });
}

#[bench]
fn bench_kmp(b: &mut Bencher) {
    b.iter(|| {
        for _ in 0..10000 {
            let kmp = KMP::new(PATTERN);
            kmp.find_all(TEXT.iter()).collect::<Vec<usize>>();
        }
    });
}
