This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] Remove *chr benchtests
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Will Newton <will dot newton at linaro dot org>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Fri, 6 Sep 2013 16:32:35 +0200
- Subject: [PATCH 1/2] Remove *chr benchtests
- Authentication-results: sourceware.org; auth=none
- References: <20130906083221 dot GB21564 at domone dot kolej dot mff dot cuni dot cz> <CANu=DmjyEkPDttrwG17aW7MM43w6t0Dio-=a_Sm0jUqpN84D_w at mail dot gmail dot com>
On Fri, Sep 06, 2013 at 11:32:06AM +0100, Will Newton wrote:
> On 6 September 2013 09:32, OndÅej BÃlka <neleai@seznam.cz> wrote:
> > Hi,
> >
> > this continue consolidation with *chr benchmarks.
> >
> > It uses a common bench-chr.h header that i derived from bench-copy.h
> > it could be factored more in future.
> >
> > An additional patch to select representative input combinations would
> > be needed.
>
> The description does not mention that things such as test output
> change and that the randomisation changes have been added. Again I
> feel like it would be much easier to review the changes if the
> functional and non-functional changes in the patch were separated.
>
> > 9 files changed, 179 insertions(+), 785 deletions(-)
>
> That is a lot of lines to go through to figure out whether a change is
> functional or not.
It simple, there is too much of redundant and duplicate code in
existing benchmarks so this is rewrite.
* benchtests/bench-memchr.c: Remove.
* benchtests/bench-memrchr.c: Likewise.
* benchtests/bench-rawmemchr.c: Likewise.
* benchtests/bench-strchr.c: Likewise.
* benchtests/bench-strlen.c: Likewise.
* benchtests/bench-strnlen.c: Likewise.
* benchtests/bench-strrchr.c: Likewise.
---
benchtests/bench-memchr.c | 133 ----------------------------
benchtests/bench-memrchr.c | 40 ---------
benchtests/bench-rawmemchr.c | 126 ---------------------------
benchtests/bench-strchr.c | 200 -------------------------------------------
benchtests/bench-strlen.c | 142 ------------------------------
benchtests/bench-strnlen.c | 132 ----------------------------
benchtests/bench-strrchr.c | 184 ---------------------------------------
7 files changed, 957 deletions(-)
delete mode 100644 benchtests/bench-memchr.c
delete mode 100644 benchtests/bench-memrchr.c
delete mode 100644 benchtests/bench-rawmemchr.c
delete mode 100644 benchtests/bench-strchr.c
delete mode 100644 benchtests/bench-strlen.c
delete mode 100644 benchtests/bench-strnlen.c
delete mode 100644 benchtests/bench-strrchr.c
diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
deleted file mode 100644
index 30c472c..0000000
--- a/benchtests/bench-memchr.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Measure memchr functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#ifndef USE_AS_MEMRCHR
-# define TEST_MAIN
-# define TEST_NAME "memchr"
-# include "bench-string.h"
-
-typedef char *(*proto_t) (const char *, int, size_t);
-char *simple_memchr (const char *, int, size_t);
-
-IMPL (simple_memchr, 0)
-IMPL (memchr, 1)
-
-char *
-simple_memchr (const char *s, int c, size_t n)
-{
- while (n--)
- if (*s++ == (char) c)
- return (char *) s - 1;
- return NULL;
-}
-#endif
-
-static void
-do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res)
-{
- char *res = CALL (impl, s, c, n);
- size_t i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
-
- if (res != exp_res)
- {
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, exp_res);
- ret = 1;
- return;
- }
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s, c, n);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t pos, size_t len, int seek_char)
-{
- size_t i;
- char *result;
-
- align &= 7;
- if (align + len >= page_size)
- return;
-
- for (i = 0; i < len; ++i)
- {
- buf1[align + i] = 1 + 23 * i % 127;
- if (buf1[align + i] == seek_char)
- buf1[align + i] = seek_char + 1;
- }
- buf1[align + len] = 0;
-
- if (pos < len)
- {
- buf1[align + pos] = seek_char;
- buf1[align + len] = -seek_char;
- result = (char *) (buf1 + align + pos);
- }
- else
- {
- result = NULL;
- buf1[align + len] = seek_char;
- }
-
- printf ("Length %4zd, alignment %2zd:", pos, align);
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (char *) (buf1 + align), seek_char, len, result);
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, 16 << i, 2048, 23);
- do_test (i, 64, 256, 23);
- do_test (0, 16 << i, 2048, 0);
- do_test (i, 64, 256, 0);
- }
- for (i = 1; i < 32; ++i)
- {
- do_test (0, i, i + 1, 23);
- do_test (0, i, i + 1, 0);
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
diff --git a/benchtests/bench-memrchr.c b/benchtests/bench-memrchr.c
deleted file mode 100644
index 96a597f..0000000
--- a/benchtests/bench-memrchr.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Measure memrchr functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_MAIN
-#define TEST_NAME "memrchr"
-#include "bench-string.h"
-
-typedef char *(*proto_t) (const char *, int, size_t);
-char *simple_memrchr (const char *, int, size_t);
-
-IMPL (simple_memrchr, 0)
-IMPL (memrchr, 1)
-
-char *
-simple_memrchr (const char *s, int c, size_t n)
-{
- s = s + n;
- while (n--)
- if (*--s == (char) c)
- return (char *) s;
- return NULL;
-}
-
-#define USE_AS_MEMRCHR
-#include "bench-memchr.c"
diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c
deleted file mode 100644
index df6a310..0000000
--- a/benchtests/bench-rawmemchr.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Measure memchr functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#include <assert.h>
-
-#define TEST_MAIN
-#define TEST_NAME "rawmemchr"
-#include "bench-string.h"
-
-typedef char *(*proto_t) (const char *, int);
-char *simple_rawmemchr (const char *, int);
-
-IMPL (simple_rawmemchr, 0)
-IMPL (rawmemchr, 1)
-
-char *
-simple_rawmemchr (const char *s, int c)
-{
- while (1)
- if (*s++ == (char) c)
- return (char *) s - 1;
- return NULL;
-}
-
-static void
-do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
-{
- size_t i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
- char *res = CALL (impl, s, c);
- if (res != exp_res)
- {
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, exp_res);
- ret = 1;
- return;
- }
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s, c);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t pos, size_t len, int seek_char)
-{
- size_t i;
- char *result;
-
- align &= 7;
- if (align + len >= page_size)
- return;
-
- for (i = 0; i < len; ++i)
- {
- buf1[align + i] = 1 + 23 * i % 127;
- if (buf1[align + i] == seek_char)
- buf1[align + i] = seek_char + 1;
- }
- buf1[align + len] = 0;
-
- assert (pos < len);
-
- buf1[align + pos] = seek_char;
- buf1[align + len] = -seek_char;
- result = (char *) (buf1 + align + pos);
-
- printf ("Length %4zd, alignment %2zd:", pos, align);
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (char *) (buf1 + align), seek_char, result);
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- for (i = 1; i < 7; ++i)
- {
- do_test (0, 16 << i, 2048, 23);
- do_test (i, 64, 256, 23);
- do_test (0, 16 << i, 2048, 0);
- do_test (i, 64, 256, 0);
- }
- for (i = 1; i < 32; ++i)
- {
- do_test (0, i, i + 1, 23);
- do_test (0, i, i + 1, 0);
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
deleted file mode 100644
index d432ba5..0000000
--- a/benchtests/bench-strchr.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/* Measure STRCHR functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_MAIN
-#ifndef WIDE
-# ifdef USE_FOR_STRCHRNUL
-# define TEST_NAME "strchrnul"
-# else
-# define TEST_NAME "strchr"
-# endif
-#else
-# define TEST_NAME "wcschr"
-#endif
-#include "bench-string.h"
-
-#ifndef WIDE
-# ifdef USE_FOR_STRCHRNUL
-# define STRCHR strchrnul
-# define stupid_STRCHR stupid_STRCHRNUL
-# define simple_STRCHR simple_STRCHRNUL
-# else
-# define STRCHR strchr
-# endif
-# define STRLEN strlen
-# define CHAR char
-# define BIG_CHAR CHAR_MAX
-# define MIDDLE_CHAR 127
-# define SMALL_CHAR 23
-# define UCHAR unsigned char
-#else
-# include <wchar.h>
-# define STRCHR wcschr
-# define STRLEN wcslen
-# define CHAR wchar_t
-# define BIG_CHAR WCHAR_MAX
-# define MIDDLE_CHAR 1121
-# define SMALL_CHAR 851
-# define UCHAR wchar_t
-#endif
-
-#ifdef USE_FOR_STRCHRNUL
-# define NULLRET(endptr) endptr
-#else
-# define NULLRET(endptr) NULL
-#endif
-
-
-typedef CHAR *(*proto_t) (const CHAR *, int);
-
-CHAR *
-simple_STRCHR (const CHAR *s, int c)
-{
- for (; *s != (CHAR) c; ++s)
- if (*s == '\0')
- return NULLRET ((CHAR *) s);
- return (CHAR *) s;
-}
-
-CHAR *
-stupid_STRCHR (const CHAR *s, int c)
-{
- size_t n = STRLEN (s) + 1;
-
- while (n--)
- if (*s++ == (CHAR) c)
- return (CHAR *) s - 1;
- return NULLRET ((CHAR *) s - 1);
-}
-
-IMPL (stupid_STRCHR, 0)
-IMPL (simple_STRCHR, 0)
-IMPL (STRCHR, 1)
-
-static void
-do_one_test (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res)
-{
- size_t i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s, c);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
-/* For wcschr: align here means align not in bytes,
- but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t))
- len for wcschr here isn't in bytes but it's number of wchar_t symbols. */
-{
- size_t i;
- CHAR *result;
- CHAR *buf = (CHAR *) buf1;
- align &= 15;
- if ((align + len) * sizeof (CHAR) >= page_size)
- return;
-
- for (i = 0; i < len; ++i)
- {
- buf[align + i] = 32 + 23 * i % max_char;
- if (buf[align + i] == seek_char)
- buf[align + i] = seek_char + 1;
- else if (buf[align + i] == 0)
- buf[align + i] = 1;
- }
- buf[align + len] = 0;
-
- if (pos < len)
- {
- buf[align + pos] = seek_char;
- result = buf + align + pos;
- }
- else if (seek_char == 0)
- result = buf + align + len;
- else
- result = NULLRET (buf + align + len);
-
- printf ("Length %4zd, alignment in bytes %2zd:",
- pos, align * sizeof (CHAR));
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, buf + align, seek_char, result);
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, 16 << i, 2048, SMALL_CHAR, MIDDLE_CHAR);
- do_test (i, 16 << i, 2048, SMALL_CHAR, MIDDLE_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (i, 64, 256, SMALL_CHAR, MIDDLE_CHAR);
- do_test (i, 64, 256, SMALL_CHAR, BIG_CHAR);
- }
-
- for (i = 0; i < 32; ++i)
- {
- do_test (0, i, i + 1, SMALL_CHAR, MIDDLE_CHAR);
- do_test (0, i, i + 1, SMALL_CHAR, BIG_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, 16 << i, 2048, 0, MIDDLE_CHAR);
- do_test (i, 16 << i, 2048, 0, MIDDLE_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (i, 64, 256, 0, MIDDLE_CHAR);
- do_test (i, 64, 256, 0, BIG_CHAR);
- }
-
- for (i = 0; i < 32; ++i)
- {
- do_test (0, i, i + 1, 0, MIDDLE_CHAR);
- do_test (0, i, i + 1, 0, BIG_CHAR);
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
diff --git a/benchtests/bench-strlen.c b/benchtests/bench-strlen.c
deleted file mode 100644
index 44c9c2b..0000000
--- a/benchtests/bench-strlen.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Measure STRLEN functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_MAIN
-#ifndef WIDE
-# define TEST_NAME "strlen"
-#else
-# define TEST_NAME "wcslen"
-#endif
-#include "bench-string.h"
-
-#ifndef WIDE
-# define STRLEN strlen
-# define CHAR char
-# define MAX_CHAR CHAR_MAX
-#else
-# include <wchar.h>
-# define STRLEN wcslen
-# define CHAR wchar_t
-# define MAX_CHAR WCHAR_MAX
-#endif
-
-typedef size_t (*proto_t) (const CHAR *);
-
-size_t
-simple_STRLEN (const CHAR *s)
-{
- const CHAR *p;
-
- for (p = s; *p; ++p);
- return p - s;
-}
-
-#ifndef WIDE
-size_t
-builtin_strlen (const CHAR *p)
-{
- return __builtin_strlen (p);
-}
-IMPL (builtin_strlen, 0)
-#endif
-
-IMPL (simple_STRLEN, 0)
-IMPL (STRLEN, 1)
-
-
-static void
-do_one_test (impl_t *impl, const CHAR *s, size_t exp_len)
-{
- size_t len = CALL (impl, s), i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
-
- if (len != exp_len)
- {
- error (0, 0, "Wrong result in function %s %zd %zd", impl->name,
- len, exp_len);
- ret = 1;
- return;
- }
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t len)
-{
- size_t i;
-
- align &= 63;
- if (align + sizeof(CHAR) * len >= page_size)
- return;
-
- CHAR *buf = (CHAR *) (buf1);
-
- for (i = 0; i < len; ++i)
- buf[align + i] = 1 + 11111 * i % MAX_CHAR;
- buf[align + len] = 0;
-
- printf ("Length %4zd, alignment %2zd:", len, align);
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (CHAR *) (buf + align), len);
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- /* Checking with only 4 * N alignments for wcslen, other alignments are wrong for wchar_t type arrays*/
-
- for (i = 1; i < 8; ++i)
- {
- do_test (sizeof(CHAR) * i, i);
- do_test (0, i);
- }
-
- for (i = 2; i <= 12; ++i)
- {
- do_test (0, 1 << i);
- do_test (sizeof(CHAR) * 7, 1 << i);
- do_test (sizeof(CHAR) * i, 1 << i);
- do_test (sizeof(CHAR) * i, (size_t)((1 << i) / 1.5));
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
diff --git a/benchtests/bench-strnlen.c b/benchtests/bench-strnlen.c
deleted file mode 100644
index 793f9be..0000000
--- a/benchtests/bench-strnlen.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Measure strlen functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_MAIN
-#define TEST_NAME "strnlen"
-#include "bench-string.h"
-
-typedef size_t (*proto_t) (const char *, size_t);
-size_t simple_strnlen (const char *, size_t);
-
-IMPL (simple_strnlen, 0)
-IMPL (strnlen, 1)
-
-size_t
-simple_strnlen (const char *s, size_t maxlen)
-{
- size_t i;
-
- for (i = 0; i < maxlen && s[i]; ++i);
- return i;
-}
-
-static void
-do_one_test (impl_t *impl, const char *s, size_t maxlen, size_t exp_len)
-{
- size_t len = CALL (impl, s, maxlen), i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
-
- if (len != exp_len)
- {
- error (0, 0, "Wrong result in function %s %zd %zd", impl->name,
- len, exp_len);
- ret = 1;
- return;
- }
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s, maxlen);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t len, size_t maxlen, int max_char)
-{
- size_t i;
-
- align &= 7;
- if (align + len >= page_size)
- return;
-
- for (i = 0; i < len; ++i)
- buf1[align + i] = 1 + 7 * i % max_char;
- buf1[align + len] = 0;
-
- printf ("Length %4zd, alignment %2zd:", len, align);
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (char *) (buf1 + align), maxlen, MIN (len, maxlen));
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, i, i - 1, 127);
- do_test (0, i, i, 127);
- do_test (0, i, i + 1, 127);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (i, i, i - 1, 127);
- do_test (i, i, i, 127);
- do_test (i, i, i + 1, 127);
- }
-
- for (i = 2; i <= 10; ++i)
- {
- do_test (0, 1 << i, 5000, 127);
- do_test (1, 1 << i, 5000, 127);
- }
-
- for (i = 1; i < 8; ++i)
- do_test (0, i, 5000, 255);
-
- for (i = 1; i < 8; ++i)
- do_test (i, i, 5000, 255);
-
- for (i = 2; i <= 10; ++i)
- {
- do_test (0, 1 << i, 5000, 255);
- do_test (1, 1 << i, 5000, 255);
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
diff --git a/benchtests/bench-strrchr.c b/benchtests/bench-strrchr.c
deleted file mode 100644
index 6a7aa84..0000000
--- a/benchtests/bench-strrchr.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Measure STRCHR functions.
- Copyright (C) 2013 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_MAIN
-#ifdef WIDE
-# define TEST_NAME "wcsrchr"
-#else
-# define TEST_NAME "strrchr"
-#endif
-#include "bench-string.h"
-
-#ifdef WIDE
-# include <wchar.h>
-# define SIMPLE_STRRCHR simple_wcsrchr
-# define STRRCHR wcsrchr
-# define CHAR wchar_t
-# define UCHAR wchar_t
-# define BIG_CHAR WCHAR_MAX
-# define SMALL_CHAR 1273
-#else
-# define SIMPLE_STRRCHR simple_strrchr
-# define STRRCHR strrchr
-# define CHAR char
-# define UCHAR unsigned char
-# define BIG_CHAR CHAR_MAX
-# define SMALL_CHAR 127
-#endif
-
-typedef CHAR *(*proto_t) (const CHAR *, int);
-CHAR *SIMPLE_STRRCHR (const CHAR *, int);
-
-IMPL (SIMPLE_STRRCHR, 0)
-IMPL (STRRCHR, 1)
-
-CHAR *
-SIMPLE_STRRCHR (const CHAR *s, int c)
-{
- const CHAR *ret = NULL;
-
- for (; *s != '\0'; ++s)
- if (*s == (CHAR) c)
- ret = s;
-
- return (CHAR *) (c == '\0' ? s : ret);
-}
-
-static void
-do_one_test (impl_t *impl, const CHAR *s, int c, CHAR *exp_res)
-{
- CHAR *res = CALL (impl, s, c);
- size_t i, iters = INNER_LOOP_ITERS;
- timing_t start, stop, cur;
-
- if (res != exp_res)
- {
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, exp_res);
- ret = 1;
- return;
- }
-
- TIMING_NOW (start);
- for (i = 0; i < iters; ++i)
- {
- CALL (impl, s, c);
- }
- TIMING_NOW (stop);
-
- TIMING_DIFF (cur, start, stop);
-
- TIMING_PRINT_MEAN ((double) cur, (double) iters);
-}
-
-static void
-do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
-/* For wcsrchr: align here means align not in bytes,
- but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t))
- len for wcschr here isn't in bytes but it's number of wchar_t symbols. */
-{
- size_t i;
- CHAR *result;
- CHAR *buf = (CHAR *) buf1;
-
- align &= 7;
- if ( (align + len) * sizeof(CHAR) >= page_size)
- return;
-
- for (i = 0; i < len; ++i)
- {
- buf[align + i] = (random () * random ()) & max_char;
- if (!buf[align + i])
- buf[align + i] = (random () * random ()) & max_char;
- if (!buf[align + i])
- buf[align + i] = 1;
- if ((i > pos || pos >= len) && buf[align + i] == seek_char)
- buf[align + i] = seek_char + 10 + (random () & 15);
- }
- buf[align + len] = 0;
-
- if (pos < len)
- {
- buf[align + pos] = seek_char;
- result = (CHAR *) (buf + align + pos);
- }
- else if (seek_char == 0)
- result = (CHAR *) (buf + align + len);
- else
- result = NULL;
-
- printf ("Length %4zd, alignment in bytes %2zd:", pos, align * sizeof(CHAR));
-
- FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (CHAR *) (buf + align), seek_char, result);
-
- putchar ('\n');
-}
-
-int
-test_main (void)
-{
- size_t i;
-
- test_init ();
-
- printf ("%20s", "");
- FOR_EACH_IMPL (impl, 0)
- printf ("\t%s", impl->name);
- putchar ('\n');
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, 16 << i, 2048, 23, SMALL_CHAR);
- do_test (i, 16 << i, 2048, 23, SMALL_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (i, 64, 256, 23, SMALL_CHAR);
- do_test (i, 64, 256, 23, BIG_CHAR);
- }
-
- for (i = 0; i < 32; ++i)
- {
- do_test (0, i, i + 1, 23, SMALL_CHAR);
- do_test (0, i, i + 1, 23, BIG_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (0, 16 << i, 2048, 0, SMALL_CHAR);
- do_test (i, 16 << i, 2048, 0, SMALL_CHAR);
- }
-
- for (i = 1; i < 8; ++i)
- {
- do_test (i, 64, 256, 0, SMALL_CHAR);
- do_test (i, 64, 256, 0, BIG_CHAR);
- }
-
- for (i = 0; i < 32; ++i)
- {
- do_test (0, i, i + 1, 0, SMALL_CHAR);
- do_test (0, i, i + 1, 0, BIG_CHAR);
- }
-
- return ret;
-}
-
-#include "../test-skeleton.c"
--
1.8.3.2