[PATCH v4 1/3] random: add rte_drand() function

Stephen Hemminger stephen at networkplumber.org
Thu May 26 17:25:14 CEST 2022


On Thu, 26 May 2022 15:20:29 +0200
Mattias Rönnblom <hofors at lysator.liu.se> wrote:

> > @@ -55,6 +58,9 @@ test_rand_perf_type(enum rand_type rand_type)
> >   		case rand_type_64:
> >   			sum += rte_rand();
> >   			break;
> > +		case rand_type_float:
> > +			sum += 1000. * rte_drand();  
> 
> Including this floating point multiplication will lead to an 
> overestimation of rte_drand() latency.
> 
> You could refactor this function to be a macro, and pass the return type 
> to as a parameter to this macro. I did just that, and on both an AMD 
> 5900X and a Cortex-A72 it didn't add more than ~5%, so I don't think 
> it's necessary.

The test is not doing anything useful with the result.
It is just a way to exercise the code.

Macros are evil, have little or no typechecking and should be avoided.


More information about the dev mailing list