diff mbox

benchtests: Add more tests for memrchr

Message ID 20170524154422.GA14778@lucon.org
State New
Headers show

Commit Message

H.J. Lu May 24, 2017, 3:44 p.m. UTC
bench-memchr.c is shared with bench-memrchr.c.  This patch adds some
tests for positions close to the beginning for memrchr, which are
equivalent to positions close to the end for memchr.

Any comments?

H.J.
---
	* benchtests/bench-memchr.c (do_test): Print out both length
	and position.
	(test_main): Also test the position close to the beginning for
	memrchr.
---
 benchtests/bench-memchr.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Rajalakshmi S May 25, 2017, 7:17 a.m. UTC | #1
On 05/24/2017 09:14 PM, H.J. Lu wrote:
>    FOR_EACH_IMPL (impl, 0)
>      do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
> @@ -143,11 +144,27 @@ test_main (void)
>        do_test (i, 64, 256, 23);
>        do_test (0, 16 << i, 2048, 0);
>        do_test (i, 64, 256, 0);
> +#ifdef USE_AS_MEMRCHR
> +      /* Also test the position close to the beginning for memrchr.  */
> +      do_test (0, i, 256, 23);
> +      do_test (0, i, 256, 0);
> +      do_test (i, i, 256, 23);
> +      do_test (i, i, 256, 0);
> +#endif
>      }
>    for (i = 1; i < 32; ++i)
>      {
>        do_test (0, i, i + 1, 23);
>        do_test (0, i, i + 1, 0);
> +      do_test (i, i, i + 1, 23);
> +      do_test (i, i, i + 1, 0);
> +#ifdef USE_AS_MEMRCHR
> +      /* Also test the position close to the beginning for memrchr.  */
> +      do_test (0, 1, i + 1, 23);
> +      do_test (0, 2, i + 1, 0);
> +      do_test (i, i, i + 1, 23);
> +      do_test (i, i, i + 1, 0);

The above two lines are repeating, instead of
       do_test (i, 1, i + 1, 23);
       do_test (i, 2, i + 1, 0);

LGTM with the above change.

> +#endif
>      }
>
>    return ret;
> -- 2.9.4
>
diff mbox

Patch

diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
index 16099ac..c95cc70 100644
--- a/benchtests/bench-memchr.c
+++ b/benchtests/bench-memchr.c
@@ -117,7 +117,8 @@  do_test (size_t align, size_t pos, size_t len, int seek_char)
       buf[align + len] = seek_char;
     }
 
-  printf ("Length %4zd, alignment %2zd:", pos, align);
+  printf ("Length %4zd, position %4zd, alignment %2zd:",
+	  len, pos, align);
 
   FOR_EACH_IMPL (impl, 0)
     do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
@@ -143,11 +144,27 @@  test_main (void)
       do_test (i, 64, 256, 23);
       do_test (0, 16 << i, 2048, 0);
       do_test (i, 64, 256, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, i, 256, 23);
+      do_test (0, i, 256, 0);
+      do_test (i, i, 256, 23);
+      do_test (i, i, 256, 0);
+#endif
     }
   for (i = 1; i < 32; ++i)
     {
       do_test (0, i, i + 1, 23);
       do_test (0, i, i + 1, 0);
+      do_test (i, i, i + 1, 23);
+      do_test (i, i, i + 1, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, 1, i + 1, 23);
+      do_test (0, 2, i + 1, 0);
+      do_test (i, i, i + 1, 23);
+      do_test (i, i, i + 1, 0);
+#endif
     }
 
   return ret;