Skip to content

Commit

Permalink
Fix compiling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Ventura authored and fkrause98 committed Sep 2, 2024
1 parent ebf6a0c commit 9c63bd0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions core/tests/vm-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ zksync_vm_benchmark_harness.workspace = true
rand.workspace = true
vise.workspace = true
tokio.workspace = true
hex.workspace = true

[dev-dependencies]
criterion.workspace = true
Expand Down
78 changes: 39 additions & 39 deletions core/tests/vm-benchmark/benches/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ use zksync_vm_benchmark_harness::{
const SAMPLE_SIZE: usize = 20;
const ZKSYNC_HOME: &str = std::env!("ZKSYNC_HOME");

fn benches_in_folder<VM: BenchmarkingVmFactory, const FULL: bool>(c: &mut Criterion) {
let mut group = c.benchmark_group(VM::LABEL.as_str());
group
.sample_size(SAMPLE_SIZE)
.measurement_time(Duration::from_secs(10));

let benches = format!(
"{}/core/tests/vm-benchmark/deployment_benchmarks",
ZKSYNC_HOME
);

for path in std::fs::read_dir(&benches).unwrap() {
let path = path.unwrap().path();

let test_contract = std::fs::read(&path).expect("failed to read file");

let code = cut_to_allowed_bytecode_size(&test_contract).unwrap();
let tx = get_deploy_tx(code);
let file_name = path.file_name().unwrap().to_str().unwrap();
let full_suffix = if FULL { "/full" } else { "" };
let bench_name = format!("{file_name}{full_suffix}");
group.bench_function(bench_name, |bencher| {
if FULL {
// Include VM initialization / drop into the measured time
bencher.iter(|| BenchmarkingVm::<VM>::default().run_transaction(black_box(&tx)));
} else {
bencher.iter_batched(
BenchmarkingVm::<VM>::default,
|mut vm| {
let result = vm.run_transaction(black_box(&tx));
(vm, result)
},
BatchSize::LargeInput, // VM can consume significant amount of RAM, especially the new one
);
}
});
}
}

// fn benches_in_folder<VM: BenchmarkingVmFactory, const FULL: bool>(c: &mut Criterion) {
// let mut group = c.benchmark_group(VM::LABEL.as_str());
// group
// .sample_size(SAMPLE_SIZE)
// .measurement_time(Duration::from_secs(10));
//
// let benches = format!(
// "{}/core/tests/vm-benchmark/deployment_benchmarks",
// ZKSYNC_HOME
// );
//
// for path in std::fs::read_dir(&benches).unwrap() {
// let path = path.unwrap().path();
//
// let test_contract = std::fs::read(&path).expect("failed to read file");
//
// let code = cut_to_allowed_bytecode_size(&test_contract).unwrap();
// let tx = get_deploy_tx(code);
// let file_name = path.file_name().unwrap().to_str().unwrap();
// let full_suffix = if FULL { "/full" } else { "" };
// let bench_name = format!("{file_name}{full_suffix}");
// group.bench_function(bench_name, |bencher| {
// if FULL {
// // Include VM initialization / drop into the measured time
// bencher.iter(|| BenchmarkingVm::<VM>::default().run_transaction(black_box(&tx)));
// } else {
// bencher.iter_batched(
// BenchmarkingVm::<VM>::default,
// |mut vm| {
// let result = vm.run_transaction(black_box(&tx));
// (vm, result)
// },
// BatchSize::LargeInput, // VM can consume significant amount of RAM, especially the new one
// );
// }
// });
// }
// }
//
pub fn program_from_file(bin_path: &str) -> Vec<u8> {
let program = std::fs::read(bin_path).unwrap();
let encoded = String::from_utf8(program).unwrap();
Expand Down

0 comments on commit 9c63bd0

Please sign in to comment.