Skip to content

Commit

Permalink
add stdlib compilation benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Aug 20, 2024
1 parent c652420 commit 622ce45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ edition.workspace = true
bench = false
doctest = false

[[bench]]
name = "compilation"
harness = false

[[test]]
name = "stdlib"
path = "tests/main.rs"
Expand All @@ -31,6 +35,7 @@ assembly = { package = "miden-assembly", path = "../assembly", version = "0.11",

[dev-dependencies]
blake3 = "1.5"
criterion = "0.5"
miden-air = { package = "miden-air", path = "../air", version = "0.11", default-features = false }
num = "0.4.1"
num-bigint = "0.4"
Expand Down
26 changes: 26 additions & 0 deletions stdlib/benches/compilation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::{path::Path, time::Duration};

use assembly::{Assembler, Library, LibraryNamespace};
use criterion::{criterion_group, criterion_main, Criterion};

fn stdlib_compilation(c: &mut Criterion) {
let mut group = c.benchmark_group("stdlib");
group.measurement_time(Duration::from_secs(10));

// Compiles the entire standard library
group.bench_function("all", |bench| {
bench.iter(|| {
let assembler = Assembler::default();

let manifest_dir = env!("CARGO_MANIFEST_DIR");
let asm_dir = Path::new(manifest_dir).join("asm");
let namespace = "std".parse::<LibraryNamespace>().expect("invalid base namespace");
Library::from_dir(asm_dir, namespace, assembler).unwrap();
});
});

group.finish();
}

criterion_group!(compilation_group, stdlib_compilation);
criterion_main!(compilation_group);

0 comments on commit 622ce45

Please sign in to comment.