diff --git a/crates/cairo-profiler/src/sierra_loader.rs b/crates/cairo-profiler/src/sierra_loader.rs index 46f3599..fef8f52 100644 --- a/crates/cairo-profiler/src/sierra_loader.rs +++ b/crates/cairo-profiler/src/sierra_loader.rs @@ -30,13 +30,6 @@ impl SierraProgramArtifact { | SierraProgramArtifact::ContractClass(program_artifact) => program_artifact, } } - - pub fn was_run_with_header(&self) -> bool { - match self { - SierraProgramArtifact::VersionedProgram(_) => true, - SierraProgramArtifact::ContractClass(_) => false, - } - } } impl CompiledArtifactsPathMap { diff --git a/crates/cairo-profiler/src/trace_reader.rs b/crates/cairo-profiler/src/trace_reader.rs index a5ccc61..b4e6806 100644 --- a/crates/cairo-profiler/src/trace_reader.rs +++ b/crates/cairo-profiler/src/trace_reader.rs @@ -199,10 +199,10 @@ fn collect_samples<'a>( .get_sierra_casm_artifacts_for_path(&absolute_source_sierra_path); let function_level_profiling_info = collect_function_level_profiling_info( - &cairo_execution_info.vm_trace, + &cairo_execution_info.casm_level_info.vm_trace, compiled_artifacts.sierra.get_program_artifact(), &compiled_artifacts.casm_debug_info, - compiled_artifacts.sierra.was_run_with_header(), + cairo_execution_info.casm_level_info.run_with_call_header, &FunctionLevelConfig::from(profiler_config), ); diff --git a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs index 3bf4576..b9114b5 100644 --- a/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs +++ b/crates/cairo-profiler/src/trace_reader/function_trace_builder.rs @@ -49,7 +49,7 @@ pub fn collect_function_level_profiling_info( trace: &[TraceEntry], program_artifact: &ProgramArtifact, casm_debug_info: &CairoProgramDebugInfo, - was_run_with_header: bool, + run_with_call_header: bool, function_level_config: &FunctionLevelConfig, ) -> FunctionLevelProfilingInfo { let program = &program_artifact.program; @@ -63,7 +63,7 @@ pub fn collect_function_level_profiling_info( // The first instruction after that is the first instruction in the original CASM program. // This logic only applies when a header was added to the CASM program, otherwise the // `real_minimal_pc` is the default one which is 1. - let real_minimal_pc = if was_run_with_header { + let real_minimal_pc = if run_with_call_header { trace.last().unwrap().pc + 1 } else { 1 @@ -84,7 +84,7 @@ pub fn collect_function_level_profiling_info( for step in trace { // Skip the header. This only makes sense when a header was added to CASM program. - if step.pc < real_minimal_pc && was_run_with_header { + if step.pc < real_minimal_pc && run_with_call_header { header_steps += 1; continue; } diff --git a/crates/trace-data/src/lib.rs b/crates/trace-data/src/lib.rs index 438e7a9..40c9dd4 100644 --- a/crates/trace-data/src/lib.rs +++ b/crates/trace-data/src/lib.rs @@ -27,9 +27,15 @@ pub struct CallTrace { /// Struct needed for function level profiling. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CairoExecutionInfo { - pub vm_trace: Vec, /// Path to a file with serialized `ContractClass` or `VersionedProgram`. pub source_sierra_path: Utf8PathBuf, + pub casm_level_info: CasmLevelInfo, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CasmLevelInfo { + pub run_with_call_header: bool, + pub vm_trace: Vec, } /// Enum representing node of a trace of a call.