terminator.rs 860 B

1234567891011121314151617181920212223242526272829
  1. use criterion::*;
  2. use ion_shell::parser::Terminator;
  3. const TEXT: &str = include_str!("test.ion");
  4. const EOF: &str = include_str!("herestring.ion");
  5. fn criterion_benchmark(c: &mut Criterion) {
  6. let mut group = c.benchmark_group("terminator-Throughput");
  7. for script in &[TEXT, EOF] {
  8. group.throughput(Throughput::Bytes(script.len() as u64));
  9. group.bench_with_input(
  10. BenchmarkId::new("terminator", script.len()),
  11. &script,
  12. |b, script| {
  13. b.iter(|| {
  14. let mut bytes = script.bytes().peekable();
  15. while bytes.peek().is_some() {
  16. let _ = Terminator::new(&mut bytes).terminate();
  17. }
  18. })
  19. },
  20. );
  21. }
  22. }
  23. criterion_group!(benches, criterion_benchmark);
  24. criterion_main!(benches);