aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <goldstein.w.n@gmail.com>2021-02-03 00:39:00 -0500
committerH.J. Lu <hjl.tools@gmail.com>2021-02-08 11:34:00 -0800
commita00e2fe3dfd3a4e218ba6c1c3445ee68322ddda9 (patch)
tree3b6ca4910217d3b5d05e879831183cd9772ea050
parent1f745ecc2109890886b161d4791e1406fdfc29b8 (diff)
downloadglibc-a00e2fe3dfd3a4e218ba6c1c3445ee68322ddda9.zip
glibc-a00e2fe3dfd3a4e218ba6c1c3445ee68322ddda9.tar.gz
glibc-a00e2fe3dfd3a4e218ba6c1c3445ee68322ddda9.tar.bz2
strchr: Add additional benchmarks and tests
This patch adds additional benchmarks and tests for string size of 4096 and several benchmarks for string size 256 with different alignments.
-rw-r--r--benchtests/bench-strchr.c26
-rw-r--r--string/test-strchr.c26
2 files changed, 50 insertions, 2 deletions
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index bf493fe..4ce2369 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -100,7 +100,7 @@ do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
size_t i;
CHAR *result;
CHAR *buf = (CHAR *) buf1;
- align &= 15;
+ align &= 127;
if ((align + len) * sizeof (CHAR) >= page_size)
return;
@@ -153,10 +153,22 @@ test_main (void)
for (i = 1; i < 8; ++i)
{
+ do_test (0, 16 << i, 4096, SMALL_CHAR, MIDDLE_CHAR);
+ do_test (i, 16 << i, 4096, 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 < 8; ++i)
+ {
+ do_test (16 * i, 256, 512, SMALL_CHAR, MIDDLE_CHAR);
+ do_test (16 * i, 256, 512, SMALL_CHAR, BIG_CHAR);
+ }
+
for (i = 0; i < 32; ++i)
{
do_test (0, i, i + 1, SMALL_CHAR, MIDDLE_CHAR);
@@ -171,10 +183,22 @@ test_main (void)
for (i = 1; i < 8; ++i)
{
+ do_test (0, 16 << i, 4096, 0, MIDDLE_CHAR);
+ do_test (i, 16 << i, 4096, 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 < 8; ++i)
+ {
+ do_test (16 * i, 256, 512, 0, MIDDLE_CHAR);
+ do_test (16 * i, 256, 512, 0, BIG_CHAR);
+ }
+
for (i = 0; i < 32; ++i)
{
do_test (0, i, i + 1, 0, MIDDLE_CHAR);
diff --git a/string/test-strchr.c b/string/test-strchr.c
index 5b60227..6c8ca54 100644
--- a/string/test-strchr.c
+++ b/string/test-strchr.c
@@ -130,7 +130,7 @@ do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char)
size_t i;
CHAR *result;
CHAR *buf = (CHAR *) buf1;
- align &= 15;
+ align &= 127;
if ((align + len) * sizeof (CHAR) >= page_size)
return;
@@ -261,10 +261,22 @@ test_main (void)
for (i = 1; i < 8; ++i)
{
+ do_test (0, 16 << i, 4096, SMALL_CHAR, MIDDLE_CHAR);
+ do_test (i, 16 << i, 4096, 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 < 8; ++i)
+ {
+ do_test (16 * i, 256, 512, SMALL_CHAR, MIDDLE_CHAR);
+ do_test (16 * i, 256, 512, SMALL_CHAR, BIG_CHAR);
+ }
+
for (i = 0; i < 32; ++i)
{
do_test (0, i, i + 1, SMALL_CHAR, MIDDLE_CHAR);
@@ -279,10 +291,22 @@ test_main (void)
for (i = 1; i < 8; ++i)
{
+ do_test (0, 16 << i, 4096, 0, MIDDLE_CHAR);
+ do_test (i, 16 << i, 4096, 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 < 8; ++i)
+ {
+ do_test (16 * i, 256, 512, 0, MIDDLE_CHAR);
+ do_test (16 * i, 256, 512, 0, BIG_CHAR);
+ }
+
for (i = 0; i < 32; ++i)
{
do_test (0, i, i + 1, 0, MIDDLE_CHAR);