"make check" times
Carlos O'Donell
carlos@redhat.com
Wed Apr 1 20:10:25 GMT 2020
On 4/1/20 3:58 PM, DJ Delorie via Libc-alpha wrote:
>
> Andreas Schwab <schwab@linux-m68k.org> writes:
>> Never expand a variable unquoted.
>
> How's this? Also, comment updated to note we assume "echo" is a
> builtin.
>
LGTM. All variable expansions quoted. Non-builtins removed for performance.
Comment added to explain what we're doing.
Even if you could run `type -t echo` to determine if echo was a builitin,
I'm not sure we could do anything different with that knowledge. It's probably
still faster to do read+echo than head.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> From 98e461fd50f1617acc78caeaa70547b92a54cf5c Mon Sep 17 00:00:00 2001
> From: DJ Delorie <dj@redhat.com>
> Date: Wed, 1 Apr 2020 15:33:00 -0400
> Subject: Optimize scripts/merge-test-results.sh
>
> The inner loop is called thousands of times per "make check" even
> if there's otherwise nothing to do. Avoid calling /bin/head all
> those times when a builtin will do.
>
> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 573a44d8cf..e75123a730 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,12 @@ case $type in
> subdir=${subdir:+$subdir/}
> for t in "$@"; do
> if [ -s "$objpfx$t.test-result" ]; then
> - head -n1 "$objpfx$t.test-result"
> + # This loop is called thousands of times even when there's
> + # nothing to do. Avoid using non-built-in commands (like
> + # /bin/head) where possible. We assume "echo" is typically a
> + # built-in.
> + read line < "$objpfx$t.test-result"
> + echo "$line"
> else
> echo "UNRESOLVED: $subdir$t"
> fi
>
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list