* [PATCH] Benchtests: Remove simple_str(n)casecmp
@ 2023-03-08 11:04 Wilco Dijkstra
2023-03-08 15:23 ` Adhemerval Zanella Netto
0 siblings, 1 reply; 2+ messages in thread
From: Wilco Dijkstra @ 2023-03-08 11:04 UTC (permalink / raw)
To: 'GNU C Library'
Remove the slow byte oriented loops. Adjust iteration count to reduce benchmark time.
---
diff --git a/benchtests/bench-strcasecmp.c b/benchtests/bench-strcasecmp.c
index fcfffdea42d72364d915f65cad98eaf9e11b585e..abc6a216e37b49c352fb84f723f88986c5364fb9 100644
--- a/benchtests/bench-strcasecmp.c
+++ b/benchtests/bench-strcasecmp.c
@@ -23,28 +23,14 @@
#include "json-lib.h"
typedef int (*proto_t) (const char *, const char *);
-static int simple_strcasecmp (const char *, const char *);
-IMPL (simple_strcasecmp, 0)
IMPL (strcasecmp, 1)
-static int
-simple_strcasecmp (const char *s1, const char *s2)
-{
- int ret;
-
- while ((ret = ((unsigned char) tolower (*s1)
- - (unsigned char) tolower (*s2))) == 0
- && *s1++)
- ++s2;
- return ret;
-}
-
static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s1,
const char *s2, int exp_result)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS8;
timing_t start, stop, cur;
int result = CALL (impl, s1, s2);
if ((exp_result == 0 && result != 0)
diff --git a/benchtests/bench-strncasecmp.c b/benchtests/bench-strncasecmp.c
index 5689a22901b918cf20bc58dc5175f552604bb878..051c17d9f78b62d22b4258e7ea04cc15759e2060 100644
--- a/benchtests/bench-strncasecmp.c
+++ b/benchtests/bench-strncasecmp.c
@@ -23,35 +23,14 @@
#include "json-lib.h"
typedef int (*proto_t) (const char *, const char *, size_t);
-static int simple_strncasecmp (const char *, const char *, size_t);
-IMPL (simple_strncasecmp, 0)
IMPL (strncasecmp, 1)
-static int
-simple_strncasecmp (const char *s1, const char *s2, size_t n)
-{
- int ret;
-
- if (n == 0)
- return 0;
-
- while ((ret = ((unsigned char) tolower (*s1)
- - (unsigned char) tolower (*s2))) == 0
- && *s1++)
- {
- if (--n == 0)
- return 0;
- ++s2;
- }
- return ret;
-}
-
static void
do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s1,
const char *s2, size_t n, int exp_result)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS8;
timing_t start, stop, cur;
TIMING_NOW (start);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Benchtests: Remove simple_str(n)casecmp
2023-03-08 11:04 [PATCH] Benchtests: Remove simple_str(n)casecmp Wilco Dijkstra
@ 2023-03-08 15:23 ` Adhemerval Zanella Netto
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella Netto @ 2023-03-08 15:23 UTC (permalink / raw)
To: Wilco Dijkstra, 'GNU C Library'
On 08/03/23 08:04, Wilco Dijkstra via Libc-alpha wrote:
>
> Remove the slow byte oriented loops. Adjust iteration count to reduce benchmark time.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> ---
>
> diff --git a/benchtests/bench-strcasecmp.c b/benchtests/bench-strcasecmp.c
> index fcfffdea42d72364d915f65cad98eaf9e11b585e..abc6a216e37b49c352fb84f723f88986c5364fb9 100644
> --- a/benchtests/bench-strcasecmp.c
> +++ b/benchtests/bench-strcasecmp.c
> @@ -23,28 +23,14 @@
> #include "json-lib.h"
>
> typedef int (*proto_t) (const char *, const char *);
> -static int simple_strcasecmp (const char *, const char *);
>
> -IMPL (simple_strcasecmp, 0)
> IMPL (strcasecmp, 1)
>
> -static int
> -simple_strcasecmp (const char *s1, const char *s2)
> -{
> - int ret;
> -
> - while ((ret = ((unsigned char) tolower (*s1)
> - - (unsigned char) tolower (*s2))) == 0
> - && *s1++)
> - ++s2;
> - return ret;
> -}
> -
> static void
> do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s1,
> const char *s2, int exp_result)
> {
> - size_t i, iters = INNER_LOOP_ITERS;
> + size_t i, iters = INNER_LOOP_ITERS8;
> timing_t start, stop, cur;
> int result = CALL (impl, s1, s2);
> if ((exp_result == 0 && result != 0)
> diff --git a/benchtests/bench-strncasecmp.c b/benchtests/bench-strncasecmp.c
> index 5689a22901b918cf20bc58dc5175f552604bb878..051c17d9f78b62d22b4258e7ea04cc15759e2060 100644
> --- a/benchtests/bench-strncasecmp.c
> +++ b/benchtests/bench-strncasecmp.c
> @@ -23,35 +23,14 @@
> #include "json-lib.h"
>
> typedef int (*proto_t) (const char *, const char *, size_t);
> -static int simple_strncasecmp (const char *, const char *, size_t);
>
> -IMPL (simple_strncasecmp, 0)
> IMPL (strncasecmp, 1)
>
> -static int
> -simple_strncasecmp (const char *s1, const char *s2, size_t n)
> -{
> - int ret;
> -
> - if (n == 0)
> - return 0;
> -
> - while ((ret = ((unsigned char) tolower (*s1)
> - - (unsigned char) tolower (*s2))) == 0
> - && *s1++)
> - {
> - if (--n == 0)
> - return 0;
> - ++s2;
> - }
> - return ret;
> -}
> -
> static void
> do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s1,
> const char *s2, size_t n, int exp_result)
> {
> - size_t i, iters = INNER_LOOP_ITERS;
> + size_t i, iters = INNER_LOOP_ITERS8;
> timing_t start, stop, cur;
>
> TIMING_NOW (start);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-08 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 11:04 [PATCH] Benchtests: Remove simple_str(n)casecmp Wilco Dijkstra
2023-03-08 15:23 ` Adhemerval Zanella Netto
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).