Skip to content

Commit

Permalink
draft: new setup for criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
fkrause98 committed Aug 30, 2024
1 parent 96cb8dc commit ebf6a0c
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions core/tests/vm-benchmark/benches/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use criterion::{
use zksync_types::Transaction;
use zksync_vm_benchmark_harness::{
cut_to_allowed_bytecode_size, get_deploy_tx, get_heavy_load_test_tx, get_load_test_deploy_tx,
get_load_test_tx, get_realistic_load_test_tx, BenchmarkingVm, BenchmarkingVmFactory, Fast, Lambda,
Legacy, LoadTestParams,
get_load_test_tx, get_realistic_load_test_tx, BenchmarkingVm, BenchmarkingVmFactory, Fast,
Lambda, Legacy, LoadTestParams,
};

const SAMPLE_SIZE: usize = 20;
Expand All @@ -20,7 +20,10 @@ fn benches_in_folder<VM: BenchmarkingVmFactory, const FULL: bool>(c: &mut Criter
.sample_size(SAMPLE_SIZE)
.measurement_time(Duration::from_secs(10));

let benches = format!("{}/core/tests/vm-benchmark/deployment_benchmarks", ZKSYNC_HOME);
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();
Expand Down Expand Up @@ -50,6 +53,32 @@ fn benches_in_folder<VM: BenchmarkingVmFactory, const FULL: bool>(c: &mut Criter
}
}

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();

if &encoded[..2] != "0x" {
panic!("Wrong hex");
}

let bin = hex::decode(&encoded[2..]).unwrap();

bin
}
// Simpler version
fn benches_in_folder<VM: BenchmarkingVmFactory, const FULL: bool>(c: &mut Criterion) {
let bench = format!(
"{}/core/tests/vm-benchmark/deployment_benchmarks/send",
ZKSYNC_HOME
);

let mut vm = BenchmarkingVm::<Fast>::default();
let code = program_from_file(&bench);
let tx = get_deploy_tx(&code[..]);
let result = vm.run_transaction(&tx);
dbg!(&result.result.is_failed());
}

fn bench_load_test<VM: BenchmarkingVmFactory>(c: &mut Criterion) {
let mut group = c.benchmark_group(VM::LABEL.as_str());
group
Expand Down

0 comments on commit ebf6a0c

Please sign in to comment.