|
|
|
@ -1,12 +1,9 @@
|
|
|
|
|
#![feature(test)]
|
|
|
|
|
extern crate test;
|
|
|
|
|
pub mod tapemachine;
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use crate::tapemachine::TapeResult;
|
|
|
|
|
use crate::tapemachine::{CharTapeMachine, TapeError};
|
|
|
|
|
use test::Bencher;
|
|
|
|
|
|
|
|
|
|
const TEST_STRING: &str = "TEST STRING 1234 \\l \\n";
|
|
|
|
|
|
|
|
|
@ -82,24 +79,4 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
|
fn bench_assert_seek(b: &mut Bencher) {
|
|
|
|
|
let mut ctm = CharTapeMachine::new(TEST_STRING.chars().collect());
|
|
|
|
|
b.iter(|| {
|
|
|
|
|
ctm.check_char(&'T');
|
|
|
|
|
ctm.seek_one().unwrap();
|
|
|
|
|
ctm.check_char(&'E');
|
|
|
|
|
ctm.seek_one().unwrap();
|
|
|
|
|
ctm.check_char(&'F');
|
|
|
|
|
ctm.seek_one().unwrap();
|
|
|
|
|
ctm.check_any(&['A', 'B', 'C', 'D', 'E', '2']);
|
|
|
|
|
ctm.seek_one().unwrap();
|
|
|
|
|
ctm.seek_whitespace();
|
|
|
|
|
ctm.check_sequence(&['S', 'T', 'R', 'I', 'N', 'T']);
|
|
|
|
|
ctm.check_sequence(&['S', 'T', 'R', 'I', 'N', 'G']);
|
|
|
|
|
ctm.check_eof();
|
|
|
|
|
ctm.rewind(0);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|