Skip to content

Commit

Permalink
feat: add final cursor to exec stat
Browse files Browse the repository at this point in the history
  • Loading branch information
aoudiamoncef committed Jun 26, 2023
1 parent d4974b3 commit 2cc3572
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions massa-client/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ impl Output for ExecutionStats {
"\tActive cursor: {}",
Style::Protocol.style(self.active_cursor)
);
println!(
"\tFinal cursor: {}",
Style::Protocol.style(self.final_cursor)
);
}
}

Expand Down
1 change: 1 addition & 0 deletions massa-execution-exports/src/test_exports/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl ExecutionController for MockExecutionController {
final_block_count: 0,
final_executed_operations_count: 0,
active_cursor: Slot::new(0, 0),
final_cursor: Slot::new(0, 0),
}
}

Expand Down
3 changes: 2 additions & 1 deletion massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ impl ExecutionState {

/// Get execution statistics
pub fn get_stats(&self) -> ExecutionStats {
self.stats_counter.get_stats(self.active_cursor)
self.stats_counter
.get_stats(self.active_cursor, self.final_cursor)
}

/// Applies the output of an execution to the final execution state.
Expand Down
3 changes: 2 additions & 1 deletion massa-execution-worker/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl ExecutionStatsCounter {
}

/// get statistics
pub fn get_stats(&self, active_cursor: Slot) -> ExecutionStats {
pub fn get_stats(&self, active_cursor: Slot, final_cursor: Slot) -> ExecutionStats {
let current_time = MassaTime::now().expect("could not get current time");
let start_time = current_time.saturating_sub(self.time_window_duration);
let map_func = |pair: &(usize, MassaTime)| -> usize {
Expand All @@ -91,6 +91,7 @@ impl ExecutionStatsCounter {
time_window_start: start_time,
time_window_end: current_time,
active_cursor,
final_cursor,
}
}
}
3 changes: 3 additions & 0 deletions massa-models/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct ExecutionStats {
pub final_executed_operations_count: usize,
/// active execution cursor slot
pub active_cursor: Slot,
/// final execution cursor slot
pub final_cursor: Slot,
}

impl std::fmt::Display for ExecutionStats {
Expand All @@ -44,6 +46,7 @@ impl std::fmt::Display for ExecutionStats {
self.final_executed_operations_count
)?;
writeln!(f, "\tActive cursor: {}", self.active_cursor)?;
writeln!(f, "\tFinal cursor: {}", self.final_cursor)?;
Ok(())
}
}
Expand Down

0 comments on commit 2cc3572

Please sign in to comment.