This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED] benchtests: Reallocate buffers for every test run


Keeping the buffers the same across test runs gives later invocations
the advantage since they access cached data.  Reallocate so that all
test runs are on equal grounds.

	* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
	every test run.
---
 ChangeLog                 |  5 +++++
 benchtests/bench-memcmp.c | 25 ++++++++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 480090e720..4362a79893 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-02  Siddhesh Poyarekar  <siddhesh@sourceware.org>
+
+	* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
+	every test run.
+
 2018-02-01  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
index 38cbdf8d5a..c7255a5b0e 100644
--- a/benchtests/bench-memcmp.c
+++ b/benchtests/bench-memcmp.c
@@ -110,20 +110,23 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result)
   if (align2 + (len + 1) * CHARBYTES >= page_size)
     return;
 
-  s1 = (CHAR *) (buf1 + align1);
-  s2 = (CHAR *) (buf2 + align2);
-
-  for (i = 0; i < len; i++)
-    s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
-
-  s1[len] = align1;
-  s2[len] = align2;
-  s2[len - 1] -= exp_result;
-
   printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
 
   FOR_EACH_IMPL (impl, 0)
-    do_one_test (impl, s1, s2, len, exp_result);
+    {
+      s1 = (CHAR *) (buf1 + align1);
+      s2 = (CHAR *) (buf2 + align2);
+
+      for (i = 0; i < len; i++)
+	s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
+
+      s1[len] = align1;
+      s2[len] = align2;
+      s2[len - 1] -= exp_result;
+
+      do_one_test (impl, s1, s2, len, exp_result);
+      realloc_bufs ();
+    }
 
   putchar ('\n');
 }
-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]