Skip to content

Instantly share code, notes, and snippets.

@eusonlito
Last active December 23, 2020 23:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save eusonlito/b8ca1e80220f3791b3ae8bfa1d3c8d76 to your computer and use it in GitHub Desktop.
Save eusonlito/b8ca1e80220f3791b3ae8bfa1d3c8d76 to your computer and use it in GitHub Desktop.
Benchmark project with different Laravel versions vs PHP versions
#!/bin/bash
phps="7.1 7.2 7.3 7.4"
laravels="5.6 5.7 5.8 6.0"
requests="500 1000"
concurrencies="50 100"
native="$1"
function csv {
for t in requests time; do
for n in $requests; do
for c in $concurrencies; do
printf "$1" >> storage/logs/ab-$t-$n-$c.csv
done
done
done
}
rm -rf storage/logs/*.log storage/logs/*.csv storage/logs/*.html
csv "Laravel,PHP 7.1,PHP 7.2,PHP 7.3,PHP 7.4"
for l in $laravels; do
rm -rf vendor
rm -rf bootstrap/cache/*.php
sed -i 's/"laravel\/framework": "[^"]\+"/"laravel\/framework": "'$l'.*"/' composer.json
composer update --no-scripts --no-dev
composer install --no-dev
if [ "$native" == "true" ]; then
php-cs-fixer fix --rules=native_function_invocation --allow-risky=yes vendor/laravel/framework/src/Illuminate/
fi
csv "\n$l"
for p in $phps; do
printf "\n\nTesting Laravel $l on PHP $p\n\n"
for n in $requests; do
for c in $concurrencies; do
url="http://$(echo $p | sed -e 's/\.//').bemycrown.local.lan/"
log="storage/logs/ab-laravel-$l-php$p-n-$n-c-$c.log"
printf "\nab -l -n $n -c $c $url > $log\n\n"
wget "$url" -O "storage/logs/ab-laravel-$l-php$p-n-$n-c-$c.html" 2> /dev/null
ab -l -n $n -c $c $url > $log
printf ','$(grep -o 'Requests per second:\s\+[0-9\.]\+' $log | awk -F' ' '{print $4}') >> storage/logs/ab-requests-$n-$c.csv
printf ','$(grep -o 'Time per request:\s\+[0-9\.]\+' $log | awk -F' ' '{print $4}' | tail -1) >> storage/logs/ab-time-$n-$c.csv
done
done
done
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment