public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] benchtests: Add more tests for memrchr
@ 2017-05-24 15:44 H.J. Lu
  2017-05-25  9:32 ` Rajalakshmi Srinivasaraghavan
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2017-05-24 15:44 UTC (permalink / raw)
  To: GNU C Library

bench-memchr.c is shared with bench-memrchr.c.  This patch adds some
tests for positions close to the beginning for memrchr, which are
equivalent to positions close to the end for memchr.

Any comments?

H.J.
---
	* benchtests/bench-memchr.c (do_test): Print out both length
	and position.
	(test_main): Also test the position close to the beginning for
	memrchr.
---
 benchtests/bench-memchr.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
index 16099ac..c95cc70 100644
--- a/benchtests/bench-memchr.c
+++ b/benchtests/bench-memchr.c
@@ -117,7 +117,8 @@ do_test (size_t align, size_t pos, size_t len, int seek_char)
       buf[align + len] = seek_char;
     }
 
-  printf ("Length %4zd, alignment %2zd:", pos, align);
+  printf ("Length %4zd, position %4zd, alignment %2zd:",
+	  len, pos, align);
 
   FOR_EACH_IMPL (impl, 0)
     do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
@@ -143,11 +144,27 @@ test_main (void)
       do_test (i, 64, 256, 23);
       do_test (0, 16 << i, 2048, 0);
       do_test (i, 64, 256, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, i, 256, 23);
+      do_test (0, i, 256, 0);
+      do_test (i, i, 256, 23);
+      do_test (i, i, 256, 0);
+#endif
     }
   for (i = 1; i < 32; ++i)
     {
       do_test (0, i, i + 1, 23);
       do_test (0, i, i + 1, 0);
+      do_test (i, i, i + 1, 23);
+      do_test (i, i, i + 1, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, 1, i + 1, 23);
+      do_test (0, 2, i + 1, 0);
+      do_test (i, i, i + 1, 23);
+      do_test (i, i, i + 1, 0);
+#endif
     }
 
   return ret;
-- 
2.9.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] benchtests: Add more tests for memrchr
  2017-05-24 15:44 [PATCH] benchtests: Add more tests for memrchr H.J. Lu
@ 2017-05-25  9:32 ` Rajalakshmi Srinivasaraghavan
  2017-06-04 16:47   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Rajalakshmi Srinivasaraghavan @ 2017-05-25  9:32 UTC (permalink / raw)
  To: libc-alpha



On 05/24/2017 09:14 PM, H.J. Lu wrote:
>    FOR_EACH_IMPL (impl, 0)
>      do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
> @@ -143,11 +144,27 @@ test_main (void)
>        do_test (i, 64, 256, 23);
>        do_test (0, 16 << i, 2048, 0);
>        do_test (i, 64, 256, 0);
> +#ifdef USE_AS_MEMRCHR
> +      /* Also test the position close to the beginning for memrchr.  */
> +      do_test (0, i, 256, 23);
> +      do_test (0, i, 256, 0);
> +      do_test (i, i, 256, 23);
> +      do_test (i, i, 256, 0);
> +#endif
>      }
>    for (i = 1; i < 32; ++i)
>      {
>        do_test (0, i, i + 1, 23);
>        do_test (0, i, i + 1, 0);
> +      do_test (i, i, i + 1, 23);
> +      do_test (i, i, i + 1, 0);
> +#ifdef USE_AS_MEMRCHR
> +      /* Also test the position close to the beginning for memrchr.  */
> +      do_test (0, 1, i + 1, 23);
> +      do_test (0, 2, i + 1, 0);
> +      do_test (i, i, i + 1, 23);
> +      do_test (i, i, i + 1, 0);

The above two lines are repeating, instead of
       do_test (i, 1, i + 1, 23);
       do_test (i, 2, i + 1, 0);

LGTM with the above change.

> +#endif
>      }
>
>    return ret;
> -- 2.9.4
>

-- 
Thanks
Rajalakshmi S

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] benchtests: Add more tests for memrchr
  2017-05-25  9:32 ` Rajalakshmi Srinivasaraghavan
@ 2017-06-04 16:47   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2017-06-04 16:47 UTC (permalink / raw)
  To: Rajalakshmi Srinivasaraghavan; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

On Thu, May 25, 2017 at 12:17 AM, Rajalakshmi Srinivasaraghavan
<raji@linux.vnet.ibm.com> wrote:
>
>
> On 05/24/2017 09:14 PM, H.J. Lu wrote:
>>
>>    FOR_EACH_IMPL (impl, 0)
>>      do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
>> @@ -143,11 +144,27 @@ test_main (void)
>>        do_test (i, 64, 256, 23);
>>        do_test (0, 16 << i, 2048, 0);
>>        do_test (i, 64, 256, 0);
>> +#ifdef USE_AS_MEMRCHR
>> +      /* Also test the position close to the beginning for memrchr.  */
>> +      do_test (0, i, 256, 23);
>> +      do_test (0, i, 256, 0);
>> +      do_test (i, i, 256, 23);
>> +      do_test (i, i, 256, 0);
>> +#endif
>>      }
>>    for (i = 1; i < 32; ++i)
>>      {
>>        do_test (0, i, i + 1, 23);
>>        do_test (0, i, i + 1, 0);
>> +      do_test (i, i, i + 1, 23);
>> +      do_test (i, i, i + 1, 0);
>> +#ifdef USE_AS_MEMRCHR
>> +      /* Also test the position close to the beginning for memrchr.  */
>> +      do_test (0, 1, i + 1, 23);
>> +      do_test (0, 2, i + 1, 0);
>> +      do_test (i, i, i + 1, 23);
>> +      do_test (i, i, i + 1, 0);
>
>
> The above two lines are repeating, instead of
>       do_test (i, 1, i + 1, 23);
>       do_test (i, 2, i + 1, 0);
>
> LGTM with the above change.
>
>
>> +#endif
>>      }
>>
>>    return ret;
>> -- 2.9.4
>>

This is what I am going to check in.

Thanks.


-- 
H.J.

[-- Attachment #2: 0001-benchtests-Add-more-tests-for-memrchr.patch --]
[-- Type: text/x-patch, Size: 2390 bytes --]

From 6b69f98dcd34d63e507cae1d8bfe83ea8d597830 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 4 Jun 2017 09:44:48 -0700
Subject: [PATCH] benchtests: Add more tests for memrchr

bench-memchr.c is shared with bench-memrchr.c.  This patch adds some
tests for positions close to the beginning for memrchr, which are
equivalent to positions close to the end for memchr.

	* benchtests/bench-memchr.c (do_test): Print out both length
	and position.
	(test_main): Also test the position close to the beginning for
	memrchr.
---
 ChangeLog                 |  7 +++++++
 benchtests/bench-memchr.c | 17 ++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 055e7af..9e824d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* benchtests/bench-memchr.c (do_test): Print out both length
+	and position.
+	(test_main): Also test the position close to the beginning for
+	memrchr.
+
 2017-06-04  Zack Weinberg  <zackw@panix.com>
 
 	* nis/nis_add.c, nis/nis_addmember.c, nis/nis_call.c
diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
index 16099ac..92b5b7f 100644
--- a/benchtests/bench-memchr.c
+++ b/benchtests/bench-memchr.c
@@ -117,7 +117,8 @@ do_test (size_t align, size_t pos, size_t len, int seek_char)
       buf[align + len] = seek_char;
     }
 
-  printf ("Length %4zd, alignment %2zd:", pos, align);
+  printf ("Length %4zd, position %4zd, alignment %2zd:",
+	  len, pos, align);
 
   FOR_EACH_IMPL (impl, 0)
     do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
@@ -143,11 +144,25 @@ test_main (void)
       do_test (i, 64, 256, 23);
       do_test (0, 16 << i, 2048, 0);
       do_test (i, 64, 256, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, i, 256, 23);
+      do_test (0, i, 256, 0);
+      do_test (i, i, 256, 23);
+      do_test (i, i, 256, 0);
+#endif
     }
   for (i = 1; i < 32; ++i)
     {
       do_test (0, i, i + 1, 23);
       do_test (0, i, i + 1, 0);
+      do_test (i, i, i + 1, 23);
+      do_test (i, i, i + 1, 0);
+#ifdef USE_AS_MEMRCHR
+      /* Also test the position close to the beginning for memrchr.  */
+      do_test (0, 1, i + 1, 23);
+      do_test (0, 2, i + 1, 0);
+#endif
     }
 
   return ret;
-- 
2.9.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-04 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 15:44 [PATCH] benchtests: Add more tests for memrchr H.J. Lu
2017-05-25  9:32 ` Rajalakshmi Srinivasaraghavan
2017-06-04 16:47   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).