Commit 87a872da authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[tools] Speed-up check-unused-bailouts.sh

Use some less-known grep flags to avoid the for loop in
check-unused-bailouts.sh, speeding it up considerably.

Before:
    $ time tools/check-unused-bailouts.sh >/dev/null

    real	0m14.717s
    user	0m6.968s
    sys	0m7.128s

After:
    $ time tools/check-unused-bailouts.sh >/dev/null

    real	0m0.514s
    user	0m0.480s
    sys	0m0.028s

Change-Id: I2178e2adaf60282865cf18272246a77bcff9d140
Reviewed-on: https://chromium-review.googlesource.com/597690Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47076}
parent 71012480
...@@ -4,13 +4,22 @@ ...@@ -4,13 +4,22 @@
# found in the LICENSE file. # found in the LICENSE file.
v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../) v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../)
bailouts=$(grep -oP 'V\(\K(k[^,]*)' "$v8_root/src/bailout-reason.h") bailouts=$(
grep \
--only-matching \
--perl-regexp 'V\(\K(k[^,]*)' \
-- "$v8_root/src/bailout-reason.h")
for bailout in $bailouts; do # Find bailouts which appear exactly once (in bailout-reason.h)
bailout_uses=$(grep -r $bailout "$v8_root/src" "$v8_root/test/cctest" | wc -l) grep \
if [ $bailout_uses -eq "1" ]; then --only-matching \
echo "Bailout reason \"$bailout\" seems to be unused." --no-filename \
fi --recursive \
done --word-regexp \
--fixed-strings "$bailouts" \
-- "$v8_root/src" "$v8_root/test/cctest" \
| sort \
| uniq -u \
| sed -e 's/.*/Bailout reason "&" seems to be unused./'
echo "Kthxbye." echo "Kthxbye."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment