diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0f2efc39c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM php:7.1.9-apache + +ARG GITHUB_OAUTH_TOKEN + +ENV COMPOSER_NO_INTERACTION=1 \ + COMPOSER_ALLOW_SUPERUSER=1 \ + PATH=/root/.composer/vendor/bin:$PATH + +RUN apt-get -qy update && \ + apt-get -qy install \ + git \ + zlib1g-dev \ + libicu-dev \ + && \ + apt-get -qy clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN docker-php-ext-configure \ + intl \ + && \ + docker-php-ext-install -j$(nproc) \ + zip \ + intl + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ + composer config -g github-oauth.github.com ${GITHUB_OAUTH_TOKEN} && \ + composer global require hirak/prestissimo + +WORKDIR /var/www/html/php-framework-benchmark diff --git a/README.md b/README.md index 6bb15f393..fd58752d4 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,11 @@ If you want to see current configuration, run `sudo sysctl -a`. ~~~ +## Docker Environment +- You need only `docker` and `docker-compose` installed +- Run `$ GITHUB_OAUTH_TOKEN= docker-compose up --build` (for Composer installs and avoid GitHub API Rate limits) +- Go to inside the container: `$ docker exec -it php-framework-benchmark bash` + ## References * [Aura](http://auraphp.com/) ([@auraphp](https://twitter.com/auraphp)) diff --git a/benchmarks/_functions.sh b/benchmarks/_functions.sh index 32fec509e..dc8b1f207 100644 --- a/benchmarks/_functions.sh +++ b/benchmarks/_functions.sh @@ -11,12 +11,14 @@ benchmark () rps=`grep "Requests per second:" "$ab_log" | cut -f 7 -d " "` # get time + i=0 count=10 total=0 - for ((i=0; i < $count; i++)); do + while [ "$i" -le $count ]; do curl "$url" > "$output" t=`tail -1 "$output" | cut -f 2 -d ':'` total=`php ./benchmarks/sum_ms.php $t $total` + i=$(( i + 1 )) done time=`php ./benchmarks/avg_ms.php $total $count` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..223fd9058 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "2" +services: + app: + build: + context: . + args: + - GITHUB_OAUTH_TOKEN=${GITHUB_OAUTH_TOKEN} + + container_name: php-framework-benchmark + + volumes: + - .:/var/www/html/php-framework-benchmark:cached + + ports: + - "80:80" diff --git a/laravel-5.3/_benchmark/setup.sh b/laravel-5.3/_benchmark/setup.sh index 6ee981b95..1fa56af58 100644 --- a/laravel-5.3/_benchmark/setup.sh +++ b/laravel-5.3/_benchmark/setup.sh @@ -2,7 +2,7 @@ composer install --no-dev --optimize-autoloader chmod o+w storage/* -sudo chmod o+w storage/framework/* +chmod o+w storage/framework/* php artisan optimize --force php artisan config:cache php artisan route:cache diff --git a/staticphp-0.9/_benchmark/setup.sh b/staticphp-0.9/_benchmark/setup.sh index 877a17e76..0e3bb7e0b 100644 --- a/staticphp-0.9/_benchmark/setup.sh +++ b/staticphp-0.9/_benchmark/setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -sudo rm -rf Application/Cache/* +rm -rf Application/Cache/* composer install --no-interaction --no-dev --optimize-autoloader chmod 777 -R Application/Cache/