]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
benchtests: Add more tests for memrchr
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 4 Jun 2017 16:44:48 +0000 (09:44 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 4 Jun 2017 16:45:09 +0000 (09:45 -0700)
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.

* benchtests/bench-memchr.c (do_test): Print out both length
and position.
(test_main): Also test the position close to the beginning for
memrchr.

ChangeLog
benchtests/bench-memchr.c

index 055e7afcd9067b5b28963aa843a1fdb875d3e926..9e824d5cff2077700bb7ab7e8125e738f3fe8ce9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * benchtests/bench-memchr.c (do_test): Print out both length
+       and position.
+       (test_main): Also test the position close to the beginning for
+       memrchr.
+
 2017-06-04  Zack Weinberg  <zackw@panix.com>
 
        * nis/nis_add.c, nis/nis_addmember.c, nis/nis_call.c
index 16099ac3a22677f9eb6674af743d683edf99c6d9..92b5b7f986fce968567011936c1114cbfc688d9b 100644 (file)
@@ -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,25 @@ 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);
+#endif
     }
 
   return ret;