Skip to content
Snippets Groups Projects
Commit 11c5ab4d authored by AdminXVII's avatar AdminXVII
Browse files

Fix the benchmark

Move the test to its own file
Copy 3 times the same program to better evaluate efficiency
Don't use `println`: buffering skews the benchmark
parent 9ee81477
No related branches found
No related tags found
No related merge requests found
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use criterion::Criterion; use criterion::*;
use ion_shell::parser::Terminator; use ion_shell::parser::Terminator;
const TEXT: &str = include_str!("test.ion"); const TEXT: &str = include_str!("test.ion");
const EOF: &str = include_str!("herestring.ion"); const EOF: &str = include_str!("herestring.ion");
fn criterion_benchmark(c: &mut Criterion) { fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("terminator", |b| { c.bench(
b.iter(|| { "terminator-throughput",
let mut bytes = TEXT.bytes().peekable(); ParameterizedBenchmark::new(
while bytes.peek().is_some() { "terminator",
let stmt = Terminator::new(&mut bytes).terminate(); |b, script| {
} b.iter(|| {
}) let mut bytes = script.bytes().peekable();
}); while bytes.peek().is_some() {
let stmt = Terminator::new(&mut bytes).terminate();
c.bench_function("terminator EOF", |b| { }
b.iter(|| { })
let mut bytes = EOF.bytes().peekable(); },
while bytes.peek().is_some() { vec![TEXT, EOF],
let stmt = Terminator::new(&mut bytes).terminate(); )
} .throughput(|script| Throughput::Bytes(script.len() as u32)),
}) );
});
} }
criterion_group!(benches, criterion_benchmark); criterion_group!(benches, criterion_benchmark);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment