in amzn-smt-ir/benches/parsing.rs [57:107]
fn bench_parse<L: Logic>(
c: &mut Criterion,
benches: impl IntoIterator<Item = impl AsRef<Path>>,
logic: L,
) where
QualIdentifier: Into<L::Var>,
{
let mut group = c.benchmark_group(format!("parsing/{:?}", logic));
for bench in benches {
let path = Path::new("../benches").join(bench);
let bench_name = path.file_name().unwrap().to_str().unwrap();
let instance_size_bytes = std::fs::metadata(&path).unwrap().len();
group.throughput(Throughput::Bytes(instance_size_bytes as u64));
group.bench_with_input(
BenchmarkId::new("amzn-smt-ir", bench_name),
&path,
|b, path| {
// Don't use `iter_with_large_drop` because we include z3's teardown time as well
b.iter(|| {
let f = File::open(path).unwrap();
let reader = BufReader::new(f);
black_box(Script::<Term<L>>::parse(reader).unwrap())
})
},
);
group.bench_with_input(
BenchmarkId::new("smt2parser", bench_name),
&path,
|b, path| {
b.iter(|| {
let f = File::open(path).unwrap();
let reader = BufReader::new(f);
black_box(
CommandStream::new(reader, SyntaxBuilder, None)
.collect::<Result<Vec<_>, _>>()
.unwrap(),
)
})
},
);
let path = path.to_str().unwrap();
group.bench_with_input(BenchmarkId::new("cvc4", bench_name), path, |b, path| {
b.iter(|| black_box(cvc4_parse_file(path)))
});
let path = CString::new(path).unwrap();
group.bench_with_input(BenchmarkId::new("z3", bench_name), &path, |b, path| {
b.iter(|| black_box(z3_parse_file(path)))
});
}
}