From f618007364b84739f6f8663c1c634fb47bbc6732 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 22 Nov 2019 16:23:22 +0100 Subject: [PATCH] [gdb/contrib] Combine sed invocations in words.sh script Currently running words.sh on all the c source and header files in the repo takes ~16s in user time: ... $ time ./gdb/contrib/words.sh \ $(find -type f -name "*.c" -o -name "*.h") \ >/dev/null real 0m7,787s user 0m16,349s sys 0m0,367s ... Rewrite the sed invocations using the -e option from this: ... | sed | sed ... into this: ... | sed \ -e -e ... and reduce user time to ~11s: ... $ time ./gdb/contrib/words.sh \ $(find -type f -name "*.c" -o -name "*.h") \ >/dev/null real 0m7,243s user 0m11,220s sys 0m0,205s ... gdb/ChangeLog: 2019-11-22 Tom de Vries * contrib/words.sh: Combine sed invocations. Change-Id: Ib08453f3712f32ed02d9f503ee960711ebb9421b --- gdb/ChangeLog | 4 ++++ gdb/contrib/words.sh | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81c6690602..25c63c7658 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-11-22 Tom de Vries + + * contrib/words.sh: Combine sed invocations. + 2019-11-21 Christian Biesinger * Makefile.in: Update. diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh index ae38539a7f..8c4fdd072f 100755 --- a/gdb/contrib/words.sh +++ b/gdb/contrib/words.sh @@ -114,12 +114,13 @@ export LC_ALL=C awk \ -f "$awkfile" \ -- "$@" \ - | sed 's/[%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \ - | sed 's/\[/\n/g' \ - | sed 's/\]/\n/g' \ - | sed 's/[0-9][0-9]*/\n/g' \ + | sed \ + -e 's/[%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \ + -e 's/\[/\n/g' \ + -e 's/\]/\n/g' \ + -e 's/[0-9][0-9]*/\n/g' \ + -e 's/[ \t]*//g' \ | tr '[:upper:]' '[:lower:]' \ - | sed 's/[ \t]*//g' \ | sort \ | uniq -c \ | awk "{ if (($minfreq == 0 || $minfreq <= \$1) \ -- 2.34.1