@@ -63,7 +63,7 @@ impl EngineApiMetrics {
6363 pub ( crate ) fn execute_metered < E , DB > (
6464 & self ,
6565 executor : E ,
66- transactions : impl Iterator < Item = Result < impl ExecutableTx < E > , BlockExecutionError > > ,
66+ mut transactions : impl Iterator < Item = Result < impl ExecutableTx < E > , BlockExecutionError > > ,
6767 state_hook : Box < dyn OnStateHook > ,
6868 ) -> Result < ( BlockExecutionOutput < E :: Receipt > , Vec < Address > ) , BlockExecutionError >
6969 where
@@ -79,27 +79,42 @@ impl EngineApiMetrics {
7979 let mut executor = executor. with_state_hook ( Some ( Box :: new ( wrapper) ) ) ;
8080
8181 let f = || {
82+ let start = Instant :: now ( ) ;
8283 debug_span ! ( target: "engine::tree" , "pre execution" )
8384 . entered ( )
8485 . in_scope ( || executor. apply_pre_execution_changes ( ) ) ?;
86+ self . executor . pre_execution_histogram . record ( start. elapsed ( ) ) ;
87+
8588 let exec_span = debug_span ! ( target: "engine::tree" , "execution" ) . entered ( ) ;
86- for tx in transactions {
89+ loop {
90+ let start = Instant :: now ( ) ;
91+ let Some ( tx) = transactions. next ( ) else { break } ;
92+ self . executor . transaction_wait_histogram . record ( start. elapsed ( ) ) ;
93+
8794 let tx = tx?;
95+ senders. push ( * tx. signer ( ) ) ;
96+
8897 let span =
8998 debug_span ! ( target: "engine::tree" , "execute tx" , tx_hash=?tx. tx( ) . tx_hash( ) ) ;
9099 let enter = span. entered ( ) ;
91100 trace ! ( target: "engine::tree" , "Executing transaction" ) ;
92- senders . push ( * tx . signer ( ) ) ;
101+ let start = Instant :: now ( ) ;
93102 let gas_used = executor. execute_transaction ( tx) ?;
103+ self . executor . transaction_execution_histogram . record ( start. elapsed ( ) ) ;
94104
95105 // record the tx gas used
96106 enter. record ( "gas_used" , gas_used) ;
97107 }
98108 drop ( exec_span) ;
99- debug_span ! ( target: "engine::tree" , "finish" )
109+
110+ let start = Instant :: now ( ) ;
111+ let result = debug_span ! ( target: "engine::tree" , "finish" )
100112 . entered ( )
101113 . in_scope ( || executor. finish ( ) )
102- . map ( |( evm, result) | ( evm. into_db ( ) , result) )
114+ . map ( |( evm, result) | ( evm. into_db ( ) , result) ) ;
115+ self . executor . post_execution_histogram . record ( start. elapsed ( ) ) ;
116+
117+ result
103118 } ;
104119
105120 // Use metered to execute and track timing/gas metrics
0 commit comments