Skip to content

Commit

Permalink
benchtests: Reallocate buffers for every test run
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
siddhesh committed Feb 2, 2018
1 parent 39f898c commit 3dfcbfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-02 Siddhesh Poyarekar <[email protected]>

* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
every test run.

2018-02-01 Joseph Myers <[email protected]>

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
Expand Down
23 changes: 13 additions & 10 deletions benchtests/bench-memcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);

for (i = 0; i < len; i++)
s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
FOR_EACH_IMPL (impl, 0)
{
s1 = (CHAR *) (buf1 + align1);
s2 = (CHAR *) (buf2 + align2);

s1[len] = align1;
s2[len] = align2;
s2[len - 1] -= exp_result;
for (i = 0; i < len; i++)
s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;

printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
s1[len] = align1;
s2[len] = align2;
s2[len - 1] -= exp_result;

FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s1, s2, len, exp_result);
do_one_test (impl, s1, s2, len, exp_result);
realloc_bufs ();
}

putchar ('\n');
}
Expand Down

0 comments on commit 3dfcbfa

Please sign in to comment.