benchtests: Fix validate_benchout.py exceptions
[platform/upstream/glibc.git] / benchtests / bench-memcpy-large.c
index 1dea16f..0021274 100644 (file)
@@ -1,5 +1,5 @@
 /* Measure memcpy functions with large data sizes.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+   Copyright (C) 2016-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #ifndef MEMCPY_RESULT
 # define MEMCPY_RESULT(dst, len) dst
@@ -52,36 +52,44 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
+do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
+         int both_ways)
 {
   size_t i, j;
   char *s1, *s2;
-
-  align1 &= 63;
+  size_t repeats;
+  align1 &= 4095;
   if (align1 + len >= page_size)
     return;
 
-  align2 &= 63;
+  align2 &= 4095;
   if (align2 + len >= page_size)
     return;
 
   s1 = (char *) (buf1 + align1);
   s2 = (char *) (buf2 + align2);
 
-  for (i = 0, j = 1; i < len; i++, j += 23)
-    s1[i] = j;
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      for (i = 0, j = 1; i < len; i++, j += 23)
+        s1[i] = j;
 
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_attr_uint (json_ctx, "align1", (double) align1);
-  json_attr_uint (json_ctx, "align2", (double) align2);
-  json_array_begin (json_ctx, "timings");
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "align1", (double) align1);
+      json_attr_uint (json_ctx, "align2", (double) align2);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, s2, s1, len);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
+    }
 }
 
 int
@@ -109,10 +117,14 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
     {
-      do_test (&json_ctx, 0, 0, i + 7);
-      do_test (&json_ctx, 0, 3, i + 15);
-      do_test (&json_ctx, 3, 0, i + 31);
-      do_test (&json_ctx, 3, 5, i + 63);
+      do_test (&json_ctx, 0, 0, i + 7, 1);
+      do_test (&json_ctx, 0, 3, i + 15, 1);
+      do_test (&json_ctx, 3, 0, i + 31, 1);
+      do_test (&json_ctx, 3, 5, i + 63, 1);
+      do_test (&json_ctx, 0, 127, i, 1);
+      do_test (&json_ctx, 0, 255, i, 1);
+      do_test (&json_ctx, 0, 256, i, 1);
+      do_test (&json_ctx, 0, 4064, i, 1);
     }
 
   json_array_end (&json_ctx);