@@ -68,19 +68,20 @@ pub fn execute_bytecode(
6868 source_code : & str ,
6969 function_locations : & BTreeMap < usize , String > ,
7070 no_vec_runtime_memory : usize , // size of the "non-vectorized" runtime memory
71- profiler : bool ,
71+ ( profiler, display_std_out_and_stats ) : ( bool , bool ) ,
7272) -> ExecutionResult {
7373 let mut std_out = String :: new ( ) ;
7474 let mut instruction_history = ExecutionHistory :: new ( ) ;
7575 let result = execute_bytecode_helper (
7676 bytecode,
7777 public_input,
7878 private_input,
79- no_vec_runtime_memory,
8079 & mut std_out,
8180 & mut instruction_history,
82- profiler,
8381 function_locations,
82+ no_vec_runtime_memory,
83+ profiler,
84+ display_std_out_and_stats,
8485 )
8586 . unwrap_or_else ( |err| {
8687 let lines_history = & instruction_history. lines ;
@@ -152,11 +153,12 @@ fn execute_bytecode_helper(
152153 bytecode : & Bytecode ,
153154 public_input : & [ F ] ,
154155 private_input : & [ F ] ,
155- no_vec_runtime_memory : usize ,
156156 std_out : & mut String ,
157157 instruction_history : & mut ExecutionHistory ,
158- profiler : bool ,
159158 function_locations : & BTreeMap < usize , String > ,
159+ no_vec_runtime_memory : usize ,
160+ profiler : bool ,
161+ display_std_out_and_stats : bool ,
160162) -> Result < ExecutionResult , RunnerError > {
161163 // set public memory
162164 let mut memory = Memory :: new ( build_public_memory ( public_input) ) ;
@@ -254,87 +256,90 @@ fn execute_bytecode_helper(
254256
255257 let no_vec_runtime_memory = ap - initial_ap;
256258
257- // Ensure event counts match call counts in final execution
258259 if profiler {
259260 let report = crate :: diagnostics:: profiling_report ( instruction_history, function_locations) ;
260261 println ! ( "\n {report}" ) ;
261262 }
262- if !std_out. is_empty ( ) {
263- println ! ( "╔═════════════════════════════════════════════════════════════════════════╗" ) ;
264- println ! ( "║ STD-OUT ║" ) ;
265- println ! ( "╚═════════════════════════════════════════════════════════════════════════╝" ) ;
266- print ! ( "\n {std_out}" ) ;
267- println ! ( "──────────────────────────────────────────────────────────────────────────\n " ) ;
268- }
269-
270- println ! ( "╔═════════════════════════════════════════════════════════════════════════╗" ) ;
271- println ! ( "║ STATS ║" ) ;
272- println ! ( "╚═════════════════════════════════════════════════════════════════════════╝\n " ) ;
263+ if display_std_out_and_stats {
264+ if !std_out. is_empty ( ) {
265+ println ! ( "╔═════════════════════════════════════════════════════════════════════════╗" ) ;
266+ println ! ( "║ STD-OUT ║" ) ;
267+ println ! ( "╚═════════════════════════════════════════════════════════════════════════╝" ) ;
268+ print ! ( "\n {std_out}" ) ;
269+ println ! (
270+ "──────────────────────────────────────────────────────────────────────────\n "
271+ ) ;
272+ }
273273
274- println ! ( "CYCLES: {}" , pretty_integer ( cpu_cycles ) ) ;
275- println ! ( "MEMORY: {}" , pretty_integer ( memory . 0 . len ( ) ) ) ;
276- println ! ( ) ;
274+ println ! ( "╔═════════════════════════════════════════════════════════════════════════╗" ) ;
275+ println ! ( "║ STATS ║" ) ;
276+ println ! ( "╚═════════════════════════════════════════════════════════════════════════╝ \n " ) ;
277277
278- let runtime_memory_size = memory. 0 . len ( ) - ( PUBLIC_INPUT_START + public_input. len ( ) ) ;
279- println ! (
280- "Bytecode size: {}" ,
281- pretty_integer( bytecode. instructions. len( ) )
282- ) ;
283- println ! ( "Public input size: {}" , pretty_integer( public_input. len( ) ) ) ;
284- println ! (
285- "Private input size: {}" ,
286- pretty_integer( private_input. len( ) )
287- ) ;
288- println ! (
289- "Runtime memory: {} ({:.2}% vec) (no vec mem: {})" ,
290- pretty_integer( runtime_memory_size) ,
291- ( VECTOR_LEN * ( ap_vec - initial_ap_vec) ) as f64 / runtime_memory_size as f64 * 100.0 ,
292- no_vec_runtime_memory
293- ) ;
294- let used_memory_cells = memory
295- . 0
296- . iter ( )
297- . skip ( PUBLIC_INPUT_START + public_input. len ( ) )
298- . filter ( |& & x| x. is_some ( ) )
299- . count ( ) ;
300- println ! (
301- "Memory usage: {:.1}%" ,
302- used_memory_cells as f64 / runtime_memory_size as f64 * 100.0
303- ) ;
278+ println ! ( "CYCLES: {}" , pretty_integer( cpu_cycles) ) ;
279+ println ! ( "MEMORY: {}" , pretty_integer( memory. 0 . len( ) ) ) ;
280+ println ! ( ) ;
304281
305- println ! ( ) ;
306-
307- if poseidons_16. len ( ) + poseidons_24. len ( ) > 0 {
282+ let runtime_memory_size = memory. 0 . len ( ) - ( PUBLIC_INPUT_START + public_input. len ( ) ) ;
308283 println ! (
309- "Poseidon2_16 calls: {}, Poseidon2_24 calls: {} (1 poseidon per {} instructions)" ,
310- pretty_integer( poseidons_16. len( ) ) ,
311- pretty_integer( poseidons_24. len( ) ) ,
312- cpu_cycles / ( poseidons_16. len( ) + poseidons_24. len( ) )
284+ "Bytecode size: {}" ,
285+ pretty_integer( bytecode. instructions. len( ) )
313286 ) ;
314- }
315- if !dot_products. is_empty ( ) {
316- println ! ( "DotProduct calls: {}" , pretty_integer( dot_products. len( ) ) ) ;
317- }
318- if !multilinear_evals. is_empty ( ) {
287+ println ! ( "Public input size: {}" , pretty_integer( public_input. len( ) ) ) ;
319288 println ! (
320- "MultilinearEval calls : {}" ,
321- pretty_integer( multilinear_evals . len( ) )
289+ "Private input size : {}" ,
290+ pretty_integer( private_input . len( ) )
322291 ) ;
323- }
324-
325- if false {
326- println ! ( "Low level instruction counts:" ) ;
327292 println ! (
328- "COMPUTE : {} ({} ADD, {} MUL )" ,
329- add_counts + mul_counts ,
330- add_counts ,
331- mul_counts
293+ "Runtime memory : {} ({:.2}% vec) (no vec mem: {} )" ,
294+ pretty_integer ( runtime_memory_size ) ,
295+ ( VECTOR_LEN * ( ap_vec - initial_ap_vec ) ) as f64 / runtime_memory_size as f64 * 100.0 ,
296+ no_vec_runtime_memory
332297 ) ;
333- println ! ( "DEREF: {deref_counts}" ) ;
334- println ! ( "JUMP: {jump_counts}" ) ;
335- }
298+ let used_memory_cells = memory
299+ . 0
300+ . iter ( )
301+ . skip ( PUBLIC_INPUT_START + public_input. len ( ) )
302+ . filter ( |& & x| x. is_some ( ) )
303+ . count ( ) ;
304+ println ! (
305+ "Memory usage: {:.1}%" ,
306+ used_memory_cells as f64 / runtime_memory_size as f64 * 100.0
307+ ) ;
308+
309+ println ! ( ) ;
336310
337- println ! ( "──────────────────────────────────────────────────────────────────────────\n " ) ;
311+ if poseidons_16. len ( ) + poseidons_24. len ( ) > 0 {
312+ println ! (
313+ "Poseidon2_16 calls: {}, Poseidon2_24 calls: {} (1 poseidon per {} instructions)" ,
314+ pretty_integer( poseidons_16. len( ) ) ,
315+ pretty_integer( poseidons_24. len( ) ) ,
316+ cpu_cycles / ( poseidons_16. len( ) + poseidons_24. len( ) )
317+ ) ;
318+ }
319+ if !dot_products. is_empty ( ) {
320+ println ! ( "DotProduct calls: {}" , pretty_integer( dot_products. len( ) ) ) ;
321+ }
322+ if !multilinear_evals. is_empty ( ) {
323+ println ! (
324+ "MultilinearEval calls: {}" ,
325+ pretty_integer( multilinear_evals. len( ) )
326+ ) ;
327+ }
328+
329+ if false {
330+ println ! ( "Low level instruction counts:" ) ;
331+ println ! (
332+ "COMPUTE: {} ({} ADD, {} MUL)" ,
333+ add_counts + mul_counts,
334+ add_counts,
335+ mul_counts
336+ ) ;
337+ println ! ( "DEREF: {deref_counts}" ) ;
338+ println ! ( "JUMP: {jump_counts}" ) ;
339+ }
340+
341+ println ! ( "──────────────────────────────────────────────────────────────────────────\n " ) ;
342+ }
338343
339344 Ok ( ExecutionResult {
340345 no_vec_runtime_memory,
0 commit comments