2022-07-30 05:05:03 +01:00
|
|
|
use muss_interpreter::Interpreter;
|
2022-03-27 18:30:47 +01:00
|
|
|
//use mps_interpreter::MpsRunner;
|
2022-03-26 02:52:17 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{BufReader, Read, Seek};
|
|
|
|
|
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
|
|
|
2022-03-27 18:30:47 +01:00
|
|
|
/*fn interpretor_benchmark(c: &mut Criterion) {
|
2022-03-26 02:52:17 +00:00
|
|
|
let f = File::open("benches/lots_of_empty.mps").unwrap();
|
|
|
|
let mut reader = BufReader::with_capacity(1024 * 1024 /* 1 MiB */, f);
|
|
|
|
// read everything into buffer before starting
|
|
|
|
let mut buf = Vec::with_capacity(1024 * 1024);
|
|
|
|
reader.read_to_end(&mut buf).unwrap();
|
|
|
|
drop(buf);
|
|
|
|
c.bench_function("mps lots_of_empty.mps", |b| {
|
|
|
|
b.iter(|| {
|
|
|
|
//let f = File::open("benches/lots_of_empty.mps").unwrap();
|
|
|
|
//let mut reader = BufReader::new(f);
|
|
|
|
reader.rewind().unwrap();
|
|
|
|
let mps = MpsRunner::with_stream(&mut reader);
|
|
|
|
for item in mps {
|
|
|
|
match item {
|
|
|
|
Err(e) => panic!("{}", e),
|
|
|
|
Ok(_) => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
2022-03-27 18:30:47 +01:00
|
|
|
}*/
|
2022-03-26 02:52:17 +00:00
|
|
|
|
|
|
|
fn faye_benchmark(c: &mut Criterion) {
|
2022-07-30 05:05:38 +01:00
|
|
|
let f = File::open("benches/lots_of_empty.muss").unwrap();
|
2022-03-26 02:52:17 +00:00
|
|
|
let mut reader = BufReader::with_capacity(1024 * 1024 /* 1 MiB */, f);
|
|
|
|
// read everything into buffer before starting
|
|
|
|
let mut buf = Vec::with_capacity(1024 * 1024);
|
|
|
|
reader.read_to_end(&mut buf).unwrap();
|
|
|
|
drop(buf);
|
2022-07-30 05:05:38 +01:00
|
|
|
c.bench_function("muss-faye lots_of_empty.muss", |b| {
|
2022-03-26 02:52:17 +00:00
|
|
|
b.iter(|| {
|
|
|
|
//let f = File::open("benches/lots_of_empty.mps").unwrap();
|
|
|
|
//let mut reader = BufReader::new(f);
|
|
|
|
reader.rewind().unwrap();
|
2022-07-30 05:05:03 +01:00
|
|
|
let mps = Interpreter::with_stream(&mut reader);
|
2022-03-26 02:52:17 +00:00
|
|
|
for item in mps {
|
|
|
|
match item {
|
|
|
|
Err(e) => panic!("{}", e),
|
|
|
|
Ok(_) => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-30 05:06:21 +01:00
|
|
|
criterion_group!(
|
|
|
|
parse_benches,
|
|
|
|
/*interpretor_benchmark,*/ faye_benchmark
|
|
|
|
);
|
2022-03-26 02:52:17 +00:00
|
|
|
criterion_main!(parse_benches);
|