@@ -240,7 +240,9 @@ static int parse_input_args(int argc, char **argv, struct testbench_prm *tp)
240240 return ret ;
241241}
242242
243- static void test_pipeline_stats (struct testbench_prm * tp , long long delta_t )
243+ static void test_pipeline_stats (struct testbench_prm * tp , long long delta_t ,
244+ struct tb_heap_usage_record * heap_records ,
245+ int heap_records_count )
244246{
245247 long long file_cycles , pipeline_cycles ;
246248 float pipeline_mcps ;
@@ -284,22 +286,28 @@ static void test_pipeline_stats(struct testbench_prm *tp, long long delta_t)
284286 frames_out = n_out / tp -> channels_out ;
285287 printf ("Input sample (frame) count: %d (%d)\n" , n_in , n_in / tp -> channels_in );
286288 printf ("Output sample (frame) count: %d (%d)\n" , n_out , frames_out );
289+ if (heap_records_count > 0 ) {
290+ for (i = 0 ; i < heap_records_count ; i ++ )
291+ printf ("Heap usage for module %s: %u bytes\n" ,
292+ heap_records [i ].module_name , (uint32_t )heap_records [i ].heap_max );
293+ }
294+
295+ printf ("\n" );
287296 if (tp -> total_cycles ) {
288297 pipeline_cycles = tp -> total_cycles - file_cycles ;
289298 pipeline_mcps = (float )pipeline_cycles * tp -> fs_out / frames_out / 1e6 ;
299+ if (tb_check_trace (LOG_LEVEL_DEBUG ))
300+ printf ("Warning: Use -d 3 or smaller value to avoid traces to increase MCPS.\n" );
301+
290302 printf ("Total execution cycles: %lld\n" , tp -> total_cycles );
291303 printf ("File component cycles: %lld\n" , file_cycles );
292304 printf ("Pipeline cycles: %lld\n" , pipeline_cycles );
293- printf ("Pipeline MCPS: %6.2f\n" , pipeline_mcps );
294- if (tb_check_trace (LOG_LEVEL_DEBUG ))
295- printf ("Warning: Use -d 3 or smaller value to avoid traces to increase MCPS.\n" );
305+ printf ("Pipeline MCPS: %6.2f\n\n" , pipeline_mcps );
296306 }
297307
298308 if (delta_t )
299- printf ("Total execution time: %lld us, %.2f x realtime\n" ,
300- delta_t , (float )frames_out / tp -> fs_out * 1000000 / delta_t );
301-
302- printf ("\n" );
309+ printf ("Total execution time: %lld us, %.2f x realtime\n\n" , delta_t ,
310+ (float )frames_out / tp -> fs_out * 1000000 / delta_t );
303311}
304312
305313/*
@@ -308,14 +316,16 @@ static void test_pipeline_stats(struct testbench_prm *tp, long long delta_t)
308316 */
309317static int pipline_test (struct testbench_prm * tp )
310318{
311- float samples_to_ns ;
312- int dp_count = 0 ;
313- struct timespec td0 , td1 ;
319+ struct tb_heap_usage_record heap_usage_records [TB_NUM_WIDGETS_SUPPORTED ];
314320 struct file_state * out_stat ;
315- long long delta_t ;
321+ struct timespec td0 = {0 }, td1 = {0 };
322+ long long delta_t = 0 ;
316323 int64_t next_control_ns ;
317324 int64_t time_ns ;
325+ float samples_to_ns ;
318326 int err ;
327+ int heap_usage_records_count = 0 ;
328+ int dp_count = 0 ;
319329
320330 /* build, run and teardown pipelines */
321331 while (dp_count < tp -> dynamic_pipeline_iterations ) {
@@ -392,8 +402,10 @@ static int pipline_test(struct testbench_prm *tp)
392402 }
393403
394404 tb_schedule_pipeline_check_state (tp ); /* Once more to flush out remaining data */
395-
396405 tb_gettime (& td1 );
406+ delta_t = (td1 .tv_sec - td0 .tv_sec ) * 1000000 ;
407+ delta_t += (td1 .tv_nsec - td0 .tv_nsec ) / 1000 ;
408+ tb_collect_heap_usage (tp , heap_usage_records , & heap_usage_records_count );
397409
398410out :
399411 err = tb_set_reset_state (tp );
@@ -403,12 +415,7 @@ static int pipline_test(struct testbench_prm *tp)
403415 break ;
404416 }
405417
406- /* TODO: This should be printed after reset and free to get cleaner output
407- * but the file internal status would be lost there.
408- */
409- delta_t = (td1 .tv_sec - td0 .tv_sec ) * 1000000 ;
410- delta_t += (td1 .tv_nsec - td0 .tv_nsec ) / 1000 ;
411- test_pipeline_stats (tp , delta_t );
418+ test_pipeline_stats (tp , delta_t , heap_usage_records , heap_usage_records_count );
412419
413420 err = tb_free_all_pipelines (tp );
414421 if (err < 0 ) {
0 commit comments