Skip to content

Commit

Permalink
Save duration to CallInfo (#25)
Browse files Browse the repository at this point in the history
* Add time to CallInfo

* Save time to CallInfo

* Move time measure to inside of the match
  • Loading branch information
JulianGCalderon authored Dec 12, 2024
1 parent d89c06b commit eb3d553
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/blockifier/src/execution/call_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pub struct CallInfo {
pub charged_resources: ChargedResources,

// Additional information gathered during execution.
pub time: std::time::Duration,
pub storage_read_values: Vec<Felt>,
pub accessed_storage_keys: HashSet<StorageKey>,
pub read_class_hash_values: Vec<ClassHash>,
Expand Down
1 change: 1 addition & 0 deletions crates/blockifier/src/execution/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ pub fn finalize_execution(
accessed_storage_keys: syscall_handler_base.accessed_keys,
read_class_hash_values: syscall_handler_base.read_class_hash_values,
accessed_contract_addresses: syscall_handler_base.accessed_contract_addresses,
time: std::time::Duration::default(),
})
}

Expand Down
24 changes: 19 additions & 5 deletions crates/blockifier/src/execution/execution_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,26 @@ pub fn execute_entry_point_call(
) -> EntryPointExecutionResult<CallInfo> {
match compiled_class {
RunnableCompiledClass::V0(compiled_class) => {
deprecated_entry_point_execution::execute_entry_point_call(
let pre_time = std::time::Instant::now();
let mut result = deprecated_entry_point_execution::execute_entry_point_call(
call,
compiled_class,
state,
context,
)
)?;
result.time = pre_time.elapsed();
Ok(result)
}
RunnableCompiledClass::V1(compiled_class) => {
entry_point_execution::execute_entry_point_call(call, compiled_class, state, context)
let pre_time = std::time::Instant::now();
let mut result = entry_point_execution::execute_entry_point_call(
call,
compiled_class,
state,
context,
)?;
result.time = pre_time.elapsed();
Ok(result)
}
#[cfg(feature = "cairo_native")]
RunnableCompiledClass::V1Native(compiled_class) => {
Expand All @@ -136,12 +147,15 @@ pub fn execute_entry_point_call(
// context,
// )
// } else {
native_entry_point_execution::execute_entry_point_call(
let pre_time = std::time::Instant::now();
let mut result = native_entry_point_execution::execute_entry_point_call(
call,
compiled_class,
state,
context,
)
)?;
result.time = pre_time.elapsed();
Ok(result)
// }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ fn create_callinfo(
accessed_contract_addresses: syscall_handler.base.accessed_contract_addresses,
read_class_hash_values: syscall_handler.base.read_class_hash_values,
tracked_resource: TrackedResource::SierraGas,
time: std::time::Duration::default(),
})
}

0 comments on commit eb3d553

Please sign in to comment.