[DTrace-devel] [PATCH] test: Get cpc expected branches and instructions counts from perf

Kris Van Hees kris.van.hees at oracle.com
Thu Apr 24 15:37:58 UTC 2025


Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

On Sun, Apr 06, 2025 at 01:19:17AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> For a number of the cpc tests, we get expected counts from perf.
> For branches and instructions, however, we can determine the
> expected counts more directly since there is one branch and a
> fixed number of instructions per iteration.  Thus, we can derive
> an expected cpc counts simply by knowing the number of iterations.
> 
> For some compilers, however, there is apparently some loop unrolling
> even at low, default levels of optimization.
> 
> So, revert to the perf count to estimate the expected cpc count
> even for the branches and instructions tests.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  test/unittest/cpc/tst.branches.sh     | 2 +-
>  test/unittest/cpc/tst.instructions.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/test/unittest/cpc/tst.branches.sh b/test/unittest/cpc/tst.branches.sh
> index 87250c371..442d65332 100755
> --- a/test/unittest/cpc/tst.branches.sh
> +++ b/test/unittest/cpc/tst.branches.sh
> @@ -53,7 +53,7 @@ fi
>  actual=$(($period * `cat tmp.txt`))
>  
>  # determine expected count (one branch per interation)
> -expect=$niters
> +expect=`$utils/perf_count_event.sh branches workload_user $niters`
>  
>  # check
>  $utils/check_result.sh $actual $expect $(($expect / 4))
> diff --git a/test/unittest/cpc/tst.instructions.sh b/test/unittest/cpc/tst.instructions.sh
> index a7fad3e78..34112c6e7 100755
> --- a/test/unittest/cpc/tst.instructions.sh
> +++ b/test/unittest/cpc/tst.instructions.sh
> @@ -61,7 +61,7 @@ fi
>  actual=$(($period * `cat tmp.txt`))
>  
>  # determine expected count
> -expect=$(($niters * $ninstructions_per_iter))
> +expect=`$utils/perf_count_event.sh instructions workload_user $niters`
>  
>  # check
>  $utils/check_result.sh $actual $expect $(($expect / 4))
> -- 
> 2.43.5
> 



More information about the DTrace-devel mailing list