Skip to content

Commit

Permalink
chore: merged benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Eagle941 committed Sep 17, 2024
1 parent 3f61129 commit 9ba3e92
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions crates/blockifier/bench/blockifier_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use blockifier::context::BlockContext;
use blockifier::invoke_tx_args;
use blockifier::state::cached_state::{CachedState, TransactionalState};
use blockifier::state::state_api::State;
use blockifier::state::visited_pcs::VisitedPcsSet;
use blockifier::test_utils::contracts::FeatureContract;
use blockifier::test_utils::dict_state_reader::DictStateReader;
use blockifier::test_utils::initial_test_state::test_state;
Expand Down Expand Up @@ -65,7 +66,7 @@ pub fn cached_state_benchmark(c: &mut Criterion) {
}

// The state shared across all iterations.
let mut cached_state: CachedState<DictStateReader> = CachedState::default();
let mut cached_state: CachedState<DictStateReader, VisitedPcsSet> = CachedState::default();

c.bench_function("cached_state", move |benchmark| {
benchmark.iter_batched(
Expand All @@ -81,107 +82,107 @@ pub fn cached_state_benchmark(c: &mut Criterion) {
let mut random_arrays = Vec::new();

let class_hash = create_class_hash("a");
let random_array = get_random_array(11393).into_iter().collect();
let random_array: Vec<usize> = get_random_array(11393).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("a");
let random_array = get_random_array(453).into_iter().collect();
let random_array: Vec<usize> = get_random_array(453).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("a");
let random_array = get_random_array(604).into_iter().collect();
let random_array: Vec<usize> = get_random_array(604).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("a");
let random_array = get_random_array(806).into_iter().collect();
let random_array: Vec<usize> = get_random_array(806).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("b");
let random_array = get_random_array(1327).into_iter().collect();
let random_array: Vec<usize> = get_random_array(1327).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("b");
let random_array = get_random_array(1135).into_iter().collect();
let random_array: Vec<usize> = get_random_array(1135).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("b");
let random_array = get_random_array(213).into_iter().collect();
let random_array: Vec<usize> = get_random_array(213).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("b");
let random_array = get_random_array(135).into_iter().collect();
let random_array: Vec<usize> = get_random_array(135).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("c");
let random_array = get_random_array(348).into_iter().collect();
let random_array: Vec<usize> = get_random_array(348).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("c");
let random_array = get_random_array(88).into_iter().collect();
let random_array: Vec<usize> = get_random_array(88).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("c");
let random_array = get_random_array(348).into_iter().collect();
let random_array: Vec<usize> = get_random_array(348).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("c");
let random_array = get_random_array(348).into_iter().collect();
let random_array: Vec<usize> = get_random_array(348).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(875).into_iter().collect();
let random_array: Vec<usize> = get_random_array(875).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(450).into_iter().collect();
let random_array: Vec<usize> = get_random_array(450).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(255).into_iter().collect();
let random_array: Vec<usize> = get_random_array(255).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(210).into_iter().collect();
let random_array: Vec<usize> = get_random_array(210).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(1403).into_iter().collect();
let random_array: Vec<usize> = get_random_array(1403).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(210).into_iter().collect();
let random_array: Vec<usize> = get_random_array(210).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("d");
let random_array = get_random_array(210).into_iter().collect();
let random_array: Vec<usize> = get_random_array(210).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("e");
let random_array = get_random_array(2386).into_iter().collect();
let random_array: Vec<usize> = get_random_array(2386).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

let class_hash = create_class_hash("e");
let random_array = get_random_array(3602).into_iter().collect();
let random_array: Vec<usize> = get_random_array(3602).into_iter().collect();
class_hashes.push(class_hash);
random_arrays.push(random_array);

Expand All @@ -202,7 +203,8 @@ pub fn cached_state_benchmark(c: &mut Criterion) {

pub fn execution_benchmark(c: &mut Criterion) {
/// This function sets up and returns all the objects required to execute an invoke transaction.
fn prepare_account_tx() -> (AccountTransaction, CachedState<DictStateReader>, BlockContext) {
fn prepare_account_tx()
-> (AccountTransaction, CachedState<DictStateReader, VisitedPcsSet>, BlockContext) {
let block_context = block_context();
let max_resource_bounds = max_resource_bounds();
let cairo_version = CairoVersion::Cairo1;
Expand Down

0 comments on commit 9ba3e92

Please sign in to comment.