[gdb/contrib] Combine sed invocations in words.sh script
authorTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2019 15:23:22 +0000 (16:23 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2019 15:23:22 +0000 (16:23 +0100)
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 <sedprog1>
   | sed <sedprog2>
...
into this:
...
   | sed \
       -e <sedprog1>
       -e <sedprog2>
...
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  <tdevries@suse.de>

* contrib/words.sh: Combine sed invocations.

Change-Id: Ib08453f3712f32ed02d9f503ee960711ebb9421b

gdb/ChangeLog
gdb/contrib/words.sh

index 81c6690602f12619bf7377c2f5b1990dc7c1fcfa..25c63c76589e7cdcba7bf503f7f9f62fbce81f9e 100644 (file)
@@ -1,3 +1,7 @@
+2019-11-22  Tom de Vries  <tdevries@suse.de>
+
+       * contrib/words.sh: Combine sed invocations.
+
 2019-11-21  Christian Biesinger  <cbiesinger@google.com>
 
        * Makefile.in: Update.
index ae38539a7fc3185e48c6c41eebd1595f82b2065f..8c4fdd072f74d52c2984f11dbf98a83e6b3b3106 100755 (executable)
@@ -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) \
This page took 0.032066 seconds and 4 git commands to generate.