Further improve string bench timing
diff mbox series

Message ID VI1PR0801MB212726EFFE33FCA4C7E5484383FD0@VI1PR0801MB2127.eurprd08.prod.outlook.com
State New
Headers show
Series
  • Further improve string bench timing
Related show

Commit Message

Wilco Dijkstra June 27, 2019, 6:22 p.m. UTC
Further improve the timings of the string benchmarks. Ensure most take
between 1 and 4 seconds to improve accuracy.  Overall time taken increases
by 35%.

OK for commit?

2019-06-26  Wilco Dijkstra  <wdijkstr@arm.com>

        * benchtests/bench-math-inlines.c: Increase iterations.
        * benchtests/bench-memcmp.c: Likewise.
        * benchtests/bench-rawmemchr.c: Likewise.
        * benchtests/bench-strcmp.c: Likewise.
        * benchtests/bench-strcpy_chk.c: Likewise.
        * benchtests/bench-string.h (INNER_LOOP_ITERS8): Add define.
        (INNER_LOOP_ITERS_MEDIUM): Increase iterations.
        (INNER_LOOP_ITERS_SMALL): Likewise.
        * benchtests/bench-strncat.c: Increase iterations.
        * benchtests/bench-strncmp.c: Increase iterations.
        * benchtests/bench-strncpy.c: Reduce iterations for wide strings.
        * benchtests/bench-strrchr.c: Increase iterations.
        * benchtests/bench-strstr.c: Keep iterations unchanged.
	* benchtests/bench-strtod.c: Increase iterations.

--

Comments

Adhemerval Zanella June 28, 2019, 11:23 a.m. UTC | #1
On 27/06/2019 15:22, Wilco Dijkstra wrote:
> Further improve the timings of the string benchmarks. Ensure most take
> between 1 and 4 seconds to improve accuracy.  Overall time taken increases
> by 35%.
> 
> OK for commit?

LGTM.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> 
> 2019-06-26  Wilco Dijkstra  <wdijkstr@arm.com>
> 
>         * benchtests/bench-math-inlines.c: Increase iterations.
>         * benchtests/bench-memcmp.c: Likewise.
>         * benchtests/bench-rawmemchr.c: Likewise.
>         * benchtests/bench-strcmp.c: Likewise.
>         * benchtests/bench-strcpy_chk.c: Likewise.
>         * benchtests/bench-string.h (INNER_LOOP_ITERS8): Add define.
>         (INNER_LOOP_ITERS_MEDIUM): Increase iterations.
>         (INNER_LOOP_ITERS_SMALL): Likewise.
>         * benchtests/bench-strncat.c: Increase iterations.
>         * benchtests/bench-strncmp.c: Increase iterations.
>         * benchtests/bench-strncpy.c: Reduce iterations for wide strings.
>         * benchtests/bench-strrchr.c: Increase iterations.
>         * benchtests/bench-strstr.c: Keep iterations unchanged.
> 	* benchtests/bench-strtod.c: Increase iterations.
> 
> --
> 
> diff --git a/benchtests/bench-math-inlines.c b/benchtests/bench-math-inlines.c
> index aed85ca9884736d0712c4a20c67375e2c41d94c4..37331bc662d6a8b4083a5d199a209889e3569074 100644
> --- a/benchtests/bench-math-inlines.c
> +++ b/benchtests/bench-math-inlines.c
> @@ -220,7 +220,7 @@ static void
>  do_one_test (json_ctx_t *json_ctx, proto_t test_fn, volatile double *arr,
>  	     size_t len, const char *testname)
>  {
> -  size_t iters = 500;
> +  size_t iters = 2048;
>    timing_t start, stop, cur;
>  
>    json_attr_object_begin (json_ctx, testname);
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index 4f01e3100db13360baf95c69926d668f0411189d..a6af10785589a5f1da0a79d8367d85b84d061d95 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -63,7 +63,7 @@ static void
>  do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
>  	     const CHAR *s2, size_t len, int exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS;
> +  size_t i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    TIMING_NOW (start);
> diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
> index 5cdfdf7227c4238c102c5df399c6709540d36756..f7e1524d8a682c508e9384851e5a845bd88bcb40 100644
> --- a/benchtests/bench-rawmemchr.c
> +++ b/benchtests/bench-rawmemchr.c
> @@ -39,7 +39,7 @@ IMPL (generic_rawmemchr, 0)
>  static void
>  do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS_LARGE;
> +  size_t i, iters = INNER_LOOP_ITERS_LARGE * 4;
>    timing_t start, stop, cur;
>    char *res = CALL (impl, s, c);
>    if (res != exp_res)
> diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c
> index c87b3ac02bda1c35ee604dfa0551a0fa1934cb75..b8d355c3ce576fcbad30bf7434d287fbe4579432 100644
> --- a/benchtests/bench-strcmp.c
> +++ b/benchtests/bench-strcmp.c
> @@ -83,7 +83,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl,
>  	     const CHAR *s1, const CHAR *s2,
>  	     int exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS;
> +  size_t i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    TIMING_NOW (start);
> diff --git a/benchtests/bench-strcpy_chk.c b/benchtests/bench-strcpy_chk.c
> index 3030763100f3bbc03bc38aa394d967d75a09ec20..34c9c78a77922c4bcb7abe1406b7793c73684a31 100644
> --- a/benchtests/bench-strcpy_chk.c
> +++ b/benchtests/bench-strcpy_chk.c
> @@ -77,7 +77,7 @@ do_one_test (impl_t *impl, char *dst, const char *src,
>  	     size_t len, size_t dlen)
>  {
>    char *res;
> -  size_t i, iters = INNER_LOOP_ITERS;
> +  size_t i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    if (dlen <= len)
> diff --git a/benchtests/bench-string.h b/benchtests/bench-string.h
> index 7d357914fd42273fbaab70815551efdfd2b38b63..4831e210544cd4e9402ab860844cad58c575abce 100644
> --- a/benchtests/bench-string.h
> +++ b/benchtests/bench-string.h
> @@ -125,9 +125,10 @@ extern impl_t __start_impls[], __stop_impls[];
>  # define OPT_SEED 10002
>  
>  # define INNER_LOOP_ITERS 8192
> +# define INNER_LOOP_ITERS8 32768
>  # define INNER_LOOP_ITERS_LARGE 131072
> -# define INNER_LOOP_ITERS_MEDIUM 1024
> -# define INNER_LOOP_ITERS_SMALL 32
> +# define INNER_LOOP_ITERS_MEDIUM 2048
> +# define INNER_LOOP_ITERS_SMALL 256
>  
>  int ret, do_srandom;
>  unsigned int seed;
> diff --git a/benchtests/bench-strncat.c b/benchtests/bench-strncat.c
> index 7271626d506f7a0b71cd2f46e641759567d17645..e7583dfad4a376b0d338a1618ef3fd5fd8663e58 100644
> --- a/benchtests/bench-strncat.c
> +++ b/benchtests/bench-strncat.c
> @@ -51,7 +51,7 @@ IMPL (generic_strncat, 0)
>  static void
>  do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n)
>  {
> -  size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS;
> +  size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    if (CALL (impl, dst, src, n) != dst)
> diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c
> index a4f3412a8fed49fdf1813974031827fc92fdd8f3..bd3f9b287102378cf35ca8873e45c1a86679d604 100644
> --- a/benchtests/bench-strncmp.c
> +++ b/benchtests/bench-strncmp.c
> @@ -73,7 +73,7 @@ static void
>  do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1, const CHAR
>  	     *s2, size_t n, int exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS;
> +  size_t i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    TIMING_NOW (start);
> diff --git a/benchtests/bench-strncpy.c b/benchtests/bench-strncpy.c
> index c6a6799a2fae7b80c803d287c8838fd17de5f91d..a26232f423872bf6dde3ea70b662b19d5ab115f8 100644
> --- a/benchtests/bench-strncpy.c
> +++ b/benchtests/bench-strncpy.c
> @@ -54,7 +54,7 @@ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t);
>  static void
>  do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t len, size_t n)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS_LARGE;
> +  size_t i, iters = INNER_LOOP_ITERS_LARGE * (4 / CHARBYTES);
>    timing_t start, stop, cur;
>  
>    if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n))
> diff --git a/benchtests/bench-strrchr.c b/benchtests/bench-strrchr.c
> index faf64265d2a59d51b7edc453f162f18e2952b449..bdb3b41d40efa466685f11ca7338a8caef62f050 100644
> --- a/benchtests/bench-strrchr.c
> +++ b/benchtests/bench-strrchr.c
> @@ -56,7 +56,7 @@ static void
>  do_one_test (impl_t *impl, const CHAR *s, int c, CHAR *exp_res)
>  {
>    CHAR *res = CALL (impl, s, c);
> -  size_t i, iters = INNER_LOOP_ITERS;
> +  size_t i, iters = INNER_LOOP_ITERS8;
>    timing_t start, stop, cur;
>  
>    if (res != exp_res)
> diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
> index 8fc434b42ffc1d0cd6cdc1c399f85f95f52d0eea..f49d411d8cf42c5dfb5dde805e7189927834e754 100644
> --- a/benchtests/bench-strstr.c
> +++ b/benchtests/bench-strstr.c
> @@ -131,7 +131,7 @@ IMPL (basic_strstr, 0)
>  static void
>  do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS_SMALL;
> +  size_t i, iters = INNER_LOOP_ITERS_SMALL / 8;
>    timing_t start, stop, cur;
>    char *res;
>  
> diff --git a/benchtests/bench-strtod.c b/benchtests/bench-strtod.c
> index d5b2503553ef74f33cace919ae9c62f79cd11c9c..780c04ab0ade62b576ff623614a79881793327a1 100644
> --- a/benchtests/bench-strtod.c
> +++ b/benchtests/bench-strtod.c
> @@ -24,7 +24,7 @@
>  #include "bench-timing.h"
>  
>  #undef INNER_LOOP_ITERS
> -#define INNER_LOOP_ITERS 65536
> +#define INNER_LOOP_ITERS 131072
>  
>  static const char *inputs[] =
>  {
>

Patch
diff mbox series

diff --git a/benchtests/bench-math-inlines.c b/benchtests/bench-math-inlines.c
index aed85ca9884736d0712c4a20c67375e2c41d94c4..37331bc662d6a8b4083a5d199a209889e3569074 100644
--- a/benchtests/bench-math-inlines.c
+++ b/benchtests/bench-math-inlines.c
@@ -220,7 +220,7 @@  static void
 do_one_test (json_ctx_t *json_ctx, proto_t test_fn, volatile double *arr,
 	     size_t len, const char *testname)
 {
-  size_t iters = 500;
+  size_t iters = 2048;
   timing_t start, stop, cur;
 
   json_attr_object_begin (json_ctx, testname);
diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
index 4f01e3100db13360baf95c69926d668f0411189d..a6af10785589a5f1da0a79d8367d85b84d061d95 100644
--- a/benchtests/bench-memcmp.c
+++ b/benchtests/bench-memcmp.c
@@ -63,7 +63,7 @@  static void
 do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
 	     const CHAR *s2, size_t len, int exp_result)
 {
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   TIMING_NOW (start);
diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
index 5cdfdf7227c4238c102c5df399c6709540d36756..f7e1524d8a682c508e9384851e5a845bd88bcb40 100644
--- a/benchtests/bench-rawmemchr.c
+++ b/benchtests/bench-rawmemchr.c
@@ -39,7 +39,7 @@  IMPL (generic_rawmemchr, 0)
 static void
 do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
 {
-  size_t i, iters = INNER_LOOP_ITERS_LARGE;
+  size_t i, iters = INNER_LOOP_ITERS_LARGE * 4;
   timing_t start, stop, cur;
   char *res = CALL (impl, s, c);
   if (res != exp_res)
diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c
index c87b3ac02bda1c35ee604dfa0551a0fa1934cb75..b8d355c3ce576fcbad30bf7434d287fbe4579432 100644
--- a/benchtests/bench-strcmp.c
+++ b/benchtests/bench-strcmp.c
@@ -83,7 +83,7 @@  do_one_test (json_ctx_t *json_ctx, impl_t *impl,
 	     const CHAR *s1, const CHAR *s2,
 	     int exp_result)
 {
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   TIMING_NOW (start);
diff --git a/benchtests/bench-strcpy_chk.c b/benchtests/bench-strcpy_chk.c
index 3030763100f3bbc03bc38aa394d967d75a09ec20..34c9c78a77922c4bcb7abe1406b7793c73684a31 100644
--- a/benchtests/bench-strcpy_chk.c
+++ b/benchtests/bench-strcpy_chk.c
@@ -77,7 +77,7 @@  do_one_test (impl_t *impl, char *dst, const char *src,
 	     size_t len, size_t dlen)
 {
   char *res;
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   if (dlen <= len)
diff --git a/benchtests/bench-string.h b/benchtests/bench-string.h
index 7d357914fd42273fbaab70815551efdfd2b38b63..4831e210544cd4e9402ab860844cad58c575abce 100644
--- a/benchtests/bench-string.h
+++ b/benchtests/bench-string.h
@@ -125,9 +125,10 @@  extern impl_t __start_impls[], __stop_impls[];
 # define OPT_SEED 10002
 
 # define INNER_LOOP_ITERS 8192
+# define INNER_LOOP_ITERS8 32768
 # define INNER_LOOP_ITERS_LARGE 131072
-# define INNER_LOOP_ITERS_MEDIUM 1024
-# define INNER_LOOP_ITERS_SMALL 32
+# define INNER_LOOP_ITERS_MEDIUM 2048
+# define INNER_LOOP_ITERS_SMALL 256
 
 int ret, do_srandom;
 unsigned int seed;
diff --git a/benchtests/bench-strncat.c b/benchtests/bench-strncat.c
index 7271626d506f7a0b71cd2f46e641759567d17645..e7583dfad4a376b0d338a1618ef3fd5fd8663e58 100644
--- a/benchtests/bench-strncat.c
+++ b/benchtests/bench-strncat.c
@@ -51,7 +51,7 @@  IMPL (generic_strncat, 0)
 static void
 do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n)
 {
-  size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS;
+  size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   if (CALL (impl, dst, src, n) != dst)
diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c
index a4f3412a8fed49fdf1813974031827fc92fdd8f3..bd3f9b287102378cf35ca8873e45c1a86679d604 100644
--- a/benchtests/bench-strncmp.c
+++ b/benchtests/bench-strncmp.c
@@ -73,7 +73,7 @@  static void
 do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1, const CHAR
 	     *s2, size_t n, int exp_result)
 {
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   TIMING_NOW (start);
diff --git a/benchtests/bench-strncpy.c b/benchtests/bench-strncpy.c
index c6a6799a2fae7b80c803d287c8838fd17de5f91d..a26232f423872bf6dde3ea70b662b19d5ab115f8 100644
--- a/benchtests/bench-strncpy.c
+++ b/benchtests/bench-strncpy.c
@@ -54,7 +54,7 @@  typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t);
 static void
 do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t len, size_t n)
 {
-  size_t i, iters = INNER_LOOP_ITERS_LARGE;
+  size_t i, iters = INNER_LOOP_ITERS_LARGE * (4 / CHARBYTES);
   timing_t start, stop, cur;
 
   if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n))
diff --git a/benchtests/bench-strrchr.c b/benchtests/bench-strrchr.c
index faf64265d2a59d51b7edc453f162f18e2952b449..bdb3b41d40efa466685f11ca7338a8caef62f050 100644
--- a/benchtests/bench-strrchr.c
+++ b/benchtests/bench-strrchr.c
@@ -56,7 +56,7 @@  static void
 do_one_test (impl_t *impl, const CHAR *s, int c, CHAR *exp_res)
 {
   CHAR *res = CALL (impl, s, c);
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS8;
   timing_t start, stop, cur;
 
   if (res != exp_res)
diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
index 8fc434b42ffc1d0cd6cdc1c399f85f95f52d0eea..f49d411d8cf42c5dfb5dde805e7189927834e754 100644
--- a/benchtests/bench-strstr.c
+++ b/benchtests/bench-strstr.c
@@ -131,7 +131,7 @@  IMPL (basic_strstr, 0)
 static void
 do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
 {
-  size_t i, iters = INNER_LOOP_ITERS_SMALL;
+  size_t i, iters = INNER_LOOP_ITERS_SMALL / 8;
   timing_t start, stop, cur;
   char *res;
 
diff --git a/benchtests/bench-strtod.c b/benchtests/bench-strtod.c
index d5b2503553ef74f33cace919ae9c62f79cd11c9c..780c04ab0ade62b576ff623614a79881793327a1 100644
--- a/benchtests/bench-strtod.c
+++ b/benchtests/bench-strtod.c
@@ -24,7 +24,7 @@ 
 #include "bench-timing.h"
 
 #undef INNER_LOOP_ITERS
-#define INNER_LOOP_ITERS 65536
+#define INNER_LOOP_ITERS 131072
 
 static const char *inputs[] =
 {