@@ -35,7 +35,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
strcat strchr strchrnul strcmp strcpy strcspn strlen \
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok \
- strcoll
+ strcoll wordexp
string-bench-all := $(string-bench)
# We have to generate locales
new file mode 100644
@@ -0,0 +1,118 @@
+/* Measure wordexp functions.
+ Copyright (C) 2015 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 "wordexp"
+#include "bench-string.h"
+
+#include <wordexp.h>
+
+typedef int (*proto_t) (const char *, wordexp_t *, int);
+
+IMPL (wordexp, 1)
+
+
+static void
+do_one_test (impl_t *impl, const char *s1, int flag)
+{
+ size_t i, iters = INNER_LOOP_ITERS;
+ timing_t start, stop, cur;
+
+ TIMING_NOW (start);
+ for (i = 0; i < iters; ++i)
+ {
+ wordexp_t out;
+ CALL (impl, s1, &out, flag);
+ }
+ TIMING_NOW (stop);
+
+ TIMING_DIFF (cur, start, stop);
+
+ TIMING_PRINT_MEAN ((double) cur, (double) iters);
+}
+
+
+static void
+do_test (const char *s1, int flag)
+{
+
+ printf ("Pattern %s flags %i:", s1, flag);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, s1, flag);
+
+ putchar ('\n');
+}
+
+static int
+test_main (void)
+{
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ do_test ("foo", 0);
+ do_test ("ffoo", 0);
+ do_test ("ffffoo", 0);
+ do_test ("ffffffffoo", 0);
+ do_test ("ffffffffffffffffoo", 0);
+ do_test ("ffffffffffffffffffffffffffffffffoo", 0);
+do_test ("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoo", 0);
+
+ do_test ("?foo", 0);
+ do_test ("?ffoo", 0);
+ do_test ("?ffffoo", 0);
+ do_test ("?ffffffffoo", 0);
+ do_test ("?ffffffffffffffffoo", 0);
+ do_test ("?ffffffffffffffffffffffffffffffffoo", 0);
+do_test ("?ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoo", 0);
+
+
+ do_test ("*", 0);
+
+ printf ("Hundred byte IFS\n");
+
+
+ setenv("IFS"," \
+ ", 1);
+
+ do_test ("foo", 0);
+ do_test ("ffoo", 0);
+ do_test ("ffffoo", 0);
+ do_test ("ffffffffoo", 0);
+ do_test ("ffffffffffffffffoo", 0);
+ do_test ("ffffffffffffffffffffffffffffffffoo", 0);
+do_test ("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoo", 0);
+
+ do_test ("?foo", 0);
+ do_test ("?ffoo", 0);
+ do_test ("?ffffoo", 0);
+ do_test ("?ffffffffoo", 0);
+ do_test ("?ffffffffffffffffoo", 0);
+ do_test ("?ffffffffffffffffffffffffffffffffoo", 0);
+do_test ("?ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoo", 0);
+
+ do_test ("*", 0);
+
+ return ret;
+}
+
+#include "../test-skeleton.c"