about summary refs log tree commit diff
path: root/benchtests
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2022-10-29 15:19:57 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2022-11-08 19:19:35 -0800
commitca7d181b62f703ae56b7be1e27428184560f68b4 (patch)
tree7ba13edf767a4cb6e452cd093b51e99170cfa7cb /benchtests
parent2e274cd8c1ebd0bd0c43a7f2e5433685740938ca (diff)
downloadglibc-ca7d181b62f703ae56b7be1e27428184560f68b4.tar.gz
glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.tar.xz
glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.zip
string: Add len=0 to {w}memcmp{eq} tests and benchtests
len=0 is valid and fairly common so should be tested.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'benchtests')
-rw-r--r--benchtests/bench-memcmp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
index d64eaa992e..b2816baebe 100644
--- a/benchtests/bench-memcmp.c
+++ b/benchtests/bench-memcmp.c
@@ -63,7 +63,7 @@ IMPL (MEMCMP, 1)
 
 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)
+	     const CHAR *s2, size_t len)
 {
   size_t i, iters = INNER_LOOP_ITERS_LARGE;
   timing_t start, stop, cur;
@@ -87,9 +87,6 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
   size_t i;
   CHAR *s1, *s2;
 
-  if (len == 0)
-    return;
-
   align1 &= (4096 - CHARBYTES);
   if (align1 + (len + 1) * CHARBYTES >= page_size)
     return;
@@ -111,13 +108,16 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
   for (i = 0; i < len; i++)
     s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
 
-  s1[len] = align1;
-  s2[len] = align2;
-  s2[len - 1] -= exp_result;
+  if (len)
+    {
+      s1[len] = align1;
+      s2[len] = align2;
+      s2[len - 1] -= exp_result;
+    }
 
   FOR_EACH_IMPL (impl, 0)
     {
-      do_one_test (json_ctx, impl, s1, s2, len, exp_result);
+      do_one_test (json_ctx, impl, s1, s2, len);
     }
 
   json_array_end (json_ctx);
@@ -147,7 +147,7 @@ test_main (void)
   json_array_end (&json_ctx);
 
   json_array_begin (&json_ctx, "results");
-  for (i = 1; i < 32; ++i)
+  for (i = 0; i < 32; ++i)
     {
       do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 0);
       do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 1);