Re: [hackers] [sbase][PATCH] Minor optimizations for 'yes'

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Thu, 27 Jun 2019 09:10:28 +0200

Hello,

> So, we could make this as simple as
>
> s = argc > 1 ? argv[1] : "y";
> for (;;)
> puts(s);
>
> >> I think I'd prefer
> >>
> >> for (;;)
> >> puts("y");
> >>
> >> here.
> > Originally, I had a puts(3) call there, but this decreased the performance
> > from the unpatched sbase, so I changed it to some fputc calls. Calling
> > write(2) didn't help either. I researched why and it's due to some
> > buffering,
> > but adding buffering would overcomplicate the code.
>
> I think the major slowdown here is from locking and unlocking the file
> for every loop iteration. Using putchar_unlocked will be much faster
> than a plain putchar. But anyway, I think we should stick to puts(3)
> for simplicity.

I agree, yes is neither a benchmark tool nor a data generator, it just
outputs 'y' for piping into other commands.
Keep it simple.
Received on Thu Jun 27 2019 - 09:10:28 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 27 2019 - 09:12:24 CEST