[v1] Benchtests: move 'alloc_bufs' from loop in bench-memset.c

Message ID 20220205091044.2014455-1-goldstein.w.n@gmail.com
State Committed
Commit 90cbb806361a5da29a9ef99866f0b3e699fad176
Headers
Series [v1] Benchtests: move 'alloc_bufs' from loop in bench-memset.c |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Noah Goldstein Feb. 5, 2022, 9:10 a.m. UTC
  One buf allocation is sufficient. Calling `alloc_bufs' in the loop
just adds unnecessary syscall overhead.
---
 benchtests/bench-memset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

H.J. Lu Feb. 5, 2022, 5:29 p.m. UTC | #1
On Sat, Feb 5, 2022 at 1:10 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> One buf allocation is sufficient. Calling `alloc_bufs' in the loop
> just adds unnecessary syscall overhead.
> ---
>  benchtests/bench-memset.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
> index beba3fbe46..e1e2d5f176 100644
> --- a/benchtests/bench-memset.c
> +++ b/benchtests/bench-memset.c
> @@ -74,7 +74,6 @@ do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
>    FOR_EACH_IMPL (impl, 0)
>      {
>        do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
> -      alloc_bufs ();
>      }
>
>    json_array_end (json_ctx);
> @@ -88,8 +87,9 @@ test_main (void)
>    size_t i;
>    int c = 0;
>
> -  test_init ();
>
> +  test_init ();
> +  alloc_bufs ();
>    json_init (&json_ctx, 0, stdout);
>
>    json_document_begin (&json_ctx);
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  
Noah Goldstein Feb. 5, 2022, 10:58 p.m. UTC | #2
On Sat, Feb 5, 2022 at 11:29 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sat, Feb 5, 2022 at 1:10 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > One buf allocation is sufficient. Calling `alloc_bufs' in the loop
> > just adds unnecessary syscall overhead.
> > ---
> >  benchtests/bench-memset.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
> > index beba3fbe46..e1e2d5f176 100644
> > --- a/benchtests/bench-memset.c
> > +++ b/benchtests/bench-memset.c
> > @@ -74,7 +74,6 @@ do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
> >    FOR_EACH_IMPL (impl, 0)
> >      {
> >        do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
> > -      alloc_bufs ();
> >      }
> >
> >    json_array_end (json_ctx);
> > @@ -88,8 +87,9 @@ test_main (void)
> >    size_t i;
> >    int c = 0;
> >
> > -  test_init ();
> >
> > +  test_init ();
> > +  alloc_bufs ();
> >    json_init (&json_ctx, 0, stdout);
> >
> >    json_document_begin (&json_ctx);
> > --
> > 2.25.1
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.

Thanks pushed.
>
> --
> H.J.
  

Patch

diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
index beba3fbe46..e1e2d5f176 100644
--- a/benchtests/bench-memset.c
+++ b/benchtests/bench-memset.c
@@ -74,7 +74,6 @@  do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
   FOR_EACH_IMPL (impl, 0)
     {
       do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
-      alloc_bufs ();
     }
 
   json_array_end (json_ctx);
@@ -88,8 +87,9 @@  test_main (void)
   size_t i;
   int c = 0;
 
-  test_init ();
 
+  test_init ();
+  alloc_bufs ();
   json_init (&json_ctx, 0, stdout);
 
   json_document_begin (&json_ctx);