forked from PHP-CS-Fixer/PHP-CS-Fixer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.sh
31 lines (27 loc) · 933 Bytes
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
set -eu
command -v php >/dev/null 2>&1 || { echo "I require \`php\` but it's not available. Aborting." >&2; exit 255; }
command -v grep >/dev/null 2>&1 || { echo "I require \`grep\` but it's not available. Aborting." >&2; exit 255; }
command -v awk >/dev/null 2>&1 || { echo "I require \`awk\` but it's not available. Aborting." >&2; exit 255; }
BRANCH1=${1:-''}
BRANCH2=${2:-''}
if [ "" = "$BRANCH1" ] || [ "" = "$BRANCH2" ];
then
echo "Usage: bash benchmark.sh BRANCH1 BRANCH2 ...BRANCHN"
exit 1;
fi
for BRANCH in "$@"
do
git checkout "$BRANCH" > /dev/null 2>&1 &&
git reset --hard > /dev/null 2>&1 &&
printf '%s' "$BRANCH"
composer update -q
(for _ in $(seq 1 10); do php php-cs-fixer fix --dry-run 2> /dev/null ; done) | grep -i seconds | awk '
{
total += $5;
++count;
}
END {
print " mean:" (total/count) " total:" total " rounds:" count
}'
done