Skip to content

Commit

Permalink
switch back to running all benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Oct 22, 2024
1 parent e25b2f3 commit bc58369
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions benches/example_benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
use egglog::EGraph;

// Only benchmark longer running examples,
// because many of the short ones have too much variance due to the allocator being non deterministic.
// https://github.com/oxc-project/backlog/issues/89

const BENCHMARKS: &[&str] = &[
"eggcc-extraction",
"math-microbenchmark",
"herbie",
"typeinfer",
"lambda",
"python_array_optimize",
];

fn run_example(filename: &str, program: &str) {
EGraph::default()
.parse_and_run_program(Some(filename.to_owned()), program)
.unwrap();
}

pub fn criterion_benchmark(c: &mut Criterion) {
for name in BENCHMARKS {
let filename = format!("tests/{}.egg", name);
for entry in glob::glob("tests/**/*.egg").unwrap() {
let path = entry.unwrap().clone();
let path_string = path.to_string_lossy().to_string();
if path_string.contains("fail-typecheck") {
continue;
}
let name = path.file_stem().unwrap().to_string_lossy().to_string();
let filename = path.to_string_lossy().to_string();
let program = std::fs::read_to_string(&filename).unwrap();
c.bench_function(name, |b| b.iter(|| run_example(&filename, &program)));
c.bench_function(&name, |b| b.iter(|| run_example(&filename, &program)));
}
}

Expand Down

0 comments on commit bc58369

Please sign in to comment.