@@ -254,7 +254,7 @@ static void test_pipeline_get_file_stats(int pipeline_id)
254254 time = cd -> pipeline -> pipe_task -> start ;
255255 if (fcd -> fs .copy_count == 0 )
256256 fcd -> fs .copy_count = 1 ;
257- printf ("file %s: id %d: type %d: samples %d copies %d total time %zu uS avg time %zu uS\n" ,
257+ printf ("file %s: id %d: type %d: samples %d copies %d total time %lu uS avg time %lu uS\n" ,
258258 fcd -> fs .fn , cd -> ipc_config .id , cd -> drv -> type , fcd -> fs .n ,
259259 fcd -> fs .copy_count , time , time / fcd -> fs .copy_count );
260260 break ;
@@ -356,7 +356,7 @@ static int parse_input_args(int argc, char **argv, struct testbench_prm *tp)
356356 default :
357357 fprintf (stderr , "unknown option %c\n" , option );
358358 ret = - EINVAL ;
359- __attribute__ (( fallthrough ));
359+ /* fallthrough */
360360 case 'h' :
361361 print_usage (argv [0 ]);
362362 exit (EXIT_SUCCESS );
@@ -487,10 +487,16 @@ static int test_pipeline_start(struct testbench_prm *tp)
487487static bool test_pipeline_check_state (struct testbench_prm * tp , int state )
488488{
489489 struct pipeline * p ;
490+ uint64_t cycles0 , cycles1 ;
490491 int i ;
491492
493+ tb_getcycles (& cycles0 );
494+
492495 schedule_ll_run_tasks ();
493496
497+ tb_getcycles (& cycles1 );
498+ tp -> total_cycles += cycles1 - cycles0 ;
499+
494500 /* Run pipeline until EOF from fileread */
495501 for (i = 0 ; i < tp -> pipeline_num ; i ++ ) {
496502 p = get_pipeline_by_id (tp -> pipelines [i ]);
@@ -522,15 +528,17 @@ static int test_pipeline_load(struct testbench_prm *tp, struct tplg_context *ctx
522528}
523529
524530static void test_pipeline_stats (struct testbench_prm * tp ,
525- struct tplg_context * ctx , uint64_t delta )
531+ struct tplg_context * ctx , long long delta_t )
526532{
527533 int count = 1 ;
528534 struct ipc_comp_dev * icd ;
529535 struct comp_dev * cd ;
530536 struct dai_data * dd ;
531537 struct pipeline * p ;
532538 struct file_comp_data * frcd , * fwcd ;
533- int n_in , n_out ;
539+ long long file_cycles , pipeline_cycles ;
540+ float pipeline_mcps ;
541+ int n_in , n_out , frames_out ;
534542 int i ;
535543
536544 /* Get pointer to filewrite */
@@ -566,6 +574,7 @@ static void test_pipeline_stats(struct testbench_prm *tp,
566574
567575 n_in = frcd -> fs .n ;
568576 n_out = fwcd -> fs .n ;
577+ file_cycles = frcd -> fs .cycles_count + fwcd -> fs .cycles_count ;
569578
570579 /* print test summary */
571580 printf ("==========================================================\n" );
@@ -586,10 +595,25 @@ static void test_pipeline_stats(struct testbench_prm *tp,
586595 printf ("Output[%d] written to file: \"%s\"\n" ,
587596 i , tp -> output_file [i ]);
588597 }
598+ frames_out = n_out / tp -> channels_out ;
589599 printf ("Input sample (frame) count: %d (%d)\n" , n_in , n_in / tp -> channels_in );
590- printf ("Output sample (frame) count: %d (%d)\n" , n_out , n_out / tp -> channels_out );
591- printf ("Total execution time: %zu us, %.2f x realtime\n\n" ,
592- delta , (double )((double )n_out / tp -> channels_out / tp -> fs_out ) * 1000000 / delta );
600+ printf ("Output sample (frame) count: %d (%d)\n" , n_out , frames_out );
601+ if (tp -> total_cycles ) {
602+ pipeline_cycles = tp -> total_cycles - file_cycles ;
603+ pipeline_mcps = (float )pipeline_cycles * tp -> fs_out / frames_out / 1e6 ;
604+ printf ("Total execution cycles: %lld\n" , tp -> total_cycles );
605+ printf ("File component cycles: %lld\n" , file_cycles );
606+ printf ("Pipeline cycles: %lld\n" , pipeline_cycles );
607+ printf ("Pipeline MCPS: %6.2f\n" , pipeline_mcps );
608+ if (!tp -> quiet )
609+ printf ("Warning: Use -q to avoid printing to increase MCPS.\n" );
610+ }
611+
612+ if (delta_t )
613+ printf ("Total execution time: %lld us, %.2f x realtime\n" ,
614+ delta_t , (float )frames_out / tp -> fs_out * 1000000 / delta_t );
615+
616+ printf ("\n" );
593617}
594618
595619/*
@@ -602,10 +626,10 @@ static int pipline_test(struct testbench_prm *tp)
602626 struct tplg_context ctx ;
603627 struct timespec ts ;
604628 struct timespec td0 , td1 ;
629+ long long delta_t ;
605630 int err ;
606631 int nsleep_time ;
607632 int nsleep_limit ;
608- uint64_t delta ;
609633
610634 /* build, run and teardown pipelines */
611635 while (dp_count < tp -> dynamic_pipeline_iterations ) {
@@ -637,7 +661,8 @@ static int pipline_test(struct testbench_prm *tp)
637661 dp_count , err );
638662 break ;
639663 }
640- clock_gettime (CLOCK_MONOTONIC , & td0 );
664+
665+ tb_gettime (& td0 );
641666
642667 /* sleep to let the pipeline work - we exit at timeout OR
643668 * if copy iterations OR max_samples is reached (whatever first)
@@ -652,8 +677,12 @@ static int pipline_test(struct testbench_prm *tp)
652677 tp -> pipeline_duration_ms ;
653678
654679 while (nsleep_time < nsleep_limit ) {
680+ #if defined __XCC__
681+ err = 0 ;
682+ #else
655683 /* wait for next tick */
656684 err = nanosleep (& ts , & ts );
685+ #endif
657686 if (err == 0 ) {
658687 nsleep_time += tp -> tick_period_us ; /* sleep fully completed */
659688 if (test_pipeline_check_state (tp , SOF_TASK_STATE_CANCEL )) {
@@ -670,17 +699,18 @@ static int pipline_test(struct testbench_prm *tp)
670699 }
671700 }
672701
673- clock_gettime (CLOCK_MONOTONIC , & td1 );
702+ tb_gettime (& td1 );
703+
674704 err = test_pipeline_stop (tp );
675705 if (err < 0 ) {
676706 fprintf (stderr , "error: pipeline stop %d failed %d\n" ,
677707 dp_count , err );
678708 break ;
679709 }
680710
681- delta = (td1 .tv_sec - td0 .tv_sec ) * 1000000 ;
682- delta += (td1 .tv_nsec - td0 .tv_nsec ) / 1000 ;
683- test_pipeline_stats (tp , & ctx , delta );
711+ delta_t = (td1 .tv_sec - td0 .tv_sec ) * 1000000 ;
712+ delta_t += (td1 .tv_nsec - td0 .tv_nsec ) / 1000 ;
713+ test_pipeline_stats (tp , & ctx , delta_t );
684714
685715 err = test_pipeline_reset (tp );
686716 if (err < 0 ) {
@@ -705,6 +735,7 @@ int main(int argc, char **argv)
705735
706736 /* initialize input and output sample rates, files, etc. */
707737 debug = 0 ;
738+ tp .total_cycles = 0 ;
708739 tp .fs_in = 0 ;
709740 tp .fs_out = 0 ;
710741 tp .bits_in = 0 ;
0 commit comments