benchtests: Add random benchmark in bench-strchr.c
authorNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 23 Mar 2022 21:57:14 +0000 (16:57 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Fri, 25 Mar 2022 16:46:13 +0000 (11:46 -0500)
commitece0eaa3f8f2a1b5911ca57659249d8a532d5c03
treee430ccffe52d27c40e9caa561c42fe79af117f04
parent4c5200dd9fc7c5867a5c7cb7bfce083f060a378f
benchtests: Add random benchmark in bench-strchr.c

Add benchmark that randomizes whether return should be NULL or pointer
to CHAR. The rationale is on many architectures there is a choice
between a predicate execution option (i.e cmovcc on x86) or a branch.

On x86 the results for cmovcc vs branch are something along the lines
of the following:

perc-zero, Br On Result, Time Br / Time cmov
     0.10,            1,              ,0.983
     0.10,            0,              ,1.246
     0.25,            1,              ,1.035
     0.25,            0,              ,1.49
     0.33,            1,              ,1.016
     0.33,            0,              ,1.579
     0.50,            1,              ,1.228
     0.50,            0,              ,1.739
     0.66,            1,              ,1.039
     0.66,            0,              ,1.764
     0.75,            1,              ,0.996
     0.75,            0,              ,1.642
     0.90,            1,              ,1.071
     0.90,            0,              ,1.409
     1.00,            1,              ,0.937
     1.00,            0,              ,0.999
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
benchtests/bench-strchr.c