Skip to content

Multiple stacks #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
88ce5eb
Added initial docker stacks to be able to share benchmarking environm…
motin Dec 9, 2015
f069974
Storing results separately for each stack
motin Dec 9, 2015
93028ee
Framework changes necessary for all listed frameworks to run and outp…
motin Dec 9, 2015
a988715
Ability to check results stack by stack
motin Dec 9, 2015
8d10688
Include error log on results page
motin Dec 9, 2015
72fece1
Do not bail if error log happens to be empty after a run
motin Dec 9, 2015
be9c180
Results for the frameworks that actually run in the various stacks
motin Dec 9, 2015
df036ff
Re-enabled "no-framework" so that relative results can be compared ac…
motin Dec 9, 2015
79c2e76
Synced $output_dir usage
motin Dec 9, 2015
10178e5
Graphs across stacks are now comparable
motin Dec 9, 2015
0b93772
Removed comment proven to be wrong + non-altering code
motin Dec 10, 2015
8316f27
Reversed output_data require-refactoring
motin Dec 10, 2015
51c2493
Requiring libs/output_data based on env var
motin Dec 10, 2015
9907bbf
A single framework list to maintain
motin Dec 10, 2015
eb5ecbf
Using headers to output benchmark data (solved Content-Length curl is…
motin Dec 10, 2015
4a64560
Only calculate output data if specifically requested (fixes https://g…
motin Dec 10, 2015
b3b63ff
Restored list as it was before this pr
motin Dec 10, 2015
57dcaa7
Only exit on failure during development
motin Dec 10, 2015
4c5bb54
Restored parse results
motin Dec 10, 2015
7afc5c0
Preventing division by zero when calculating relative results
motin Dec 10, 2015
c74eeb8
Not using getallheaders() since it is not available in PHP 7 when usi…
motin Dec 10, 2015
8083565
Updated results
motin Dec 10, 2015
599856d
HTML-escaping error log on results page
motin Dec 10, 2015
5517da4
Docker-related parts of readme to separate file
motin Dec 10, 2015
5611c2b
Added placeholder for other results
motin Dec 10, 2015
8f75cbc
Activated opcode cache
motin Dec 10, 2015
54f5768
Including all frameworks despite stack (so that the resulting graphs …
motin Dec 10, 2015
9720d47
Updated results, including also in readme
motin Dec 10, 2015
d8abdcf
Added script to run all benchmarks against all docker stacks
motin Dec 10, 2015
c342017
Added note about source files for the used docker images
motin Dec 10, 2015
0ddaf5a
Adjusted working directories for docker stack services
motin Dec 10, 2015
19d8bd7
Docker stacks use /php-framework-benchmark/ sub-directory as well
motin Dec 10, 2015
b4d0e02
Reversed changes that were made to support requests without the php-f…
motin Dec 10, 2015
0f210a6
Added docker results export script
motin Dec 10, 2015
c41f14c
Zero out incomplete results and only allow valid results for enabled …
motin Dec 10, 2015
22a0569
Updated docker stack results
motin Dec 10, 2015
84842c3
Moved parameters for cross-stack graph consistency to query string
motin Dec 10, 2015
e720dd1
Including graphs to current results (including "no-framework")
motin Dec 10, 2015
e171242
Moved docker-related shell scripts to docker/bin/
motin Dec 11, 2015
4e137a5
Reversed usage of php_framework_benchmark_path
motin Dec 11, 2015
9861949
Added docker-compose build command to readme to ensure that all depen…
motin Dec 11, 2015
d9af4ae
Removed docker stack info from main readme
motin Dec 11, 2015
1ebe534
Updated show_fw_array.sh to use list.php directly
motin Dec 11, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/nbproject/
/output/
vendor/
34 changes: 34 additions & 0 deletions OTHER_RESULTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# PHP ORM Benchmark

## Other Results

### [motin](https://github.com/motin)

(2015-12-09)

Using [the supplied Docker Stack]((docker/README.md)):

* Ubuntu 15.04 64bit (Docker)
* Nginx 1.7.12
* PHP-FPM 5.6.4
* Zend OPcache 7.0.4-dev
* PhalconPHP 2.0.9
* PHP-FPM 7.0.0
* Zend OPcache 7.0.6-dev
* PhalconPHP 2.0.9
* HHVM 3.10.1

Running on a MacBook Pro (Retina, 15-inch, Mid 2014).

By sharing underlying software stacks, the benchmark results vary only according to the host machine's hardware specs and differing code implementations.

![Benchmark Results Graph](:large)

## PHP-FPM 5.6.4 with opcode cache

## HHVM CLI 3.10.1 (Corresponding roughly to an up-to-date PHP 5.6)

## PHP CLI 7.0.0 with opcode cache



21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ These are my benchmarks, not yours. **I encourage you to run on your (production

Note(1): All the results are run on php with `phalcon.so` and `ice.so`. If you don't load phalcon.so or ice.so, the rps except for Phalcon or Ice probably increase a bit.

If you are interested in other results, see [OTHER_RESULTS.md](OTHER_RESULTS.md).

## How to Benchmark

Install source code as <http://localhost/php-framework-benchmark/>:
Expand Down Expand Up @@ -147,9 +149,28 @@ If you want to see current configuration, run `sudo sysctl -a`.
~~~
<VirtualHost *:80>
DocumentRoot /home/vagrant/public
SetEnv php_framework_benchmark_path /home/vagrant/public/php-framework-benchmark
</VirtualHost>
~~~

## Benchmarking using the supplied Docker Stack

Use the supplied Docker Stack in order to automatically set up the following benchmarking environments:

* Ubuntu 15.04 64bit (Docker)
* Nginx 1.7.12
* PHP-FPM 5.6.4
* Zend OPcache 7.0.4-dev
* PhalconPHP 2.0.9
* PHP-FPM 7.0.0
* Zend OPcache 7.0.6-dev
* PhalconPHP 2.0.9
* HHVM 3.10.1

By sharing underlying software stacks, the benchmark results vary only according to the host machine's hardware specs and differing code implementations.

See [docker/README.md](docker/README.md)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this. I don't need it. I don't maintain the results of Docker.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not primarily for you :) It is for everyone that easily wants to run their own benchmarks. Instead of having to set-up several server environments, compile php extensions and configure their own server software to run all the different framework, they can instead simply install docker toolbox and be running within minutes.

I will remove the change from this PR in hope that you will consider this approach in the future: #41

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark results in Docker do not matter unless you or someone deploy using it.

Is your production environment Docker on Mac OS X? If not, the benchmark results might mislead you.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My production environment is Docker in AWS instances and it is trivial to run the benchmarks as well when dealing with Docker stacks. Let's discuss in #41

## References

* [Aura](http://auraphp.com/) ([@auraphp](https://twitter.com/auraphp))
Expand Down
2 changes: 1 addition & 1 deletion aura-2.0/web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
);
$kernel();

require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need the php_framework_benchmark_path?
Is it impossible to use $_SERVER['DOCUMENT_ROOT']?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not impossible, it just gets more locked-in to having to use the same sub-directory in every environment. I'll revert it.

2 changes: 1 addition & 1 deletion bear-0.10/bootstrap/contexts/prod.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
//
OK: {
$app->response->setResource($app->page)->render()->send();
require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion bear-1.0/bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// representation transfer
$page()->transfer($app->responder, $_SERVER);
require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
exit(0);
} catch (\Exception $e) {
$app->error->handle($e, $request)->transfer();
Expand Down
2 changes: 2 additions & 0 deletions bear-1.0/var/log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 1 addition & 1 deletion bear-1.0/var/www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adhoc fix for benchmarking
// Remove sub directories from URI
$_SERVER['REQUEST_URI'] = preg_replace(
'!/php-framework-benchmark/bear-1.0/var/www/index.php!',
['!/php-framework-benchmark/bear-1.0/var/www/index.php!', '!/bear-1.0/var/www/index.php!'],
'',
$_SERVER['REQUEST_URI']
);
Expand Down
10 changes: 8 additions & 2 deletions benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/sh

base="http://127.0.0.1/php-framework-benchmark"
# exit on failure
set -e

if [ "$stack" = "" ]; then
stack="local"
fi
export stack;

cd `dirname $0`

Expand All @@ -14,6 +20,6 @@ fi

cd benchmarks

sh hello_world.sh "$base"
sh hello_world.sh "$stack"

php ../bin/show_results_table.php
30 changes: 22 additions & 8 deletions benchmarks/_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,52 @@ benchmark ()
{
fw="$1"
url="$2"
ab_log="output/$fw.ab.log"
output="output/$fw.output"
ab_log="$output_dir/$fw.ab.log"
output="$output_dir/$fw.output"
benchmark_data="$output_dir/$fw.benchmark_data"

echo "ab -c 10 -t 3 $url"
ab -c 10 -t 3 "$url" > "$ab_log"
curl "$url" > "$output"
curl -H 'X-Include-Benchmark-Output-Data: 1' --dump-header "$benchmark_data" "$url" > "$output"

rps=`grep "Requests per second:" "$ab_log" | cut -f 7 -d " "`
memory=`tail -1 "$output" | cut -f 1 -d ':'`
time=`tail -1 "$output" | cut -f 2 -d ':'`
file=`tail -1 "$output" | cut -f 3 -d ':'`
memory=`grep "X-Benchmark-Output-Data:" "$benchmark_data" | cut -f 2 -d ':' | cut -f 2 -d ' '`
time=`grep "X-Benchmark-Output-Data:" "$benchmark_data" | cut -f 3 -d ':'`
file=`grep "X-Benchmark-Output-Data:" "$benchmark_data" | cut -f 4 -d ':'`
echo "$fw: $rps: $memory: $time: $file" >> "$results_file"

echo "$fw" >> "$check_file"
grep "Document Length:" "$ab_log" >> "$check_file"
grep "Failed requests:" "$ab_log" >> "$check_file"
grep 'Hello World!' "$output" >> "$check_file"
grep ':' "$output" >> "$check_file"
echo "---" >> "$check_file"

# check errors
touch "$error_file"
error=''
x=`grep 'Failed requests: 0' "$ab_log"`
x=`grep 'Failed requests: 0' "$ab_log" || true`
if [ "$x" = "" ]; then
tmp=`grep "Failed requests:" "$ab_log"`
error="$error$tmp"
fi
x=`grep 'Hello World!' "$output"`
x=`grep 'Hello World!' "$output" || true`
if [ "$x" = "" ]; then
tmp=`cat "$output"`
error="$error$tmp"
fi
if [ "$memory" = "" ]; then
tmp=`cat "$benchmark_data"`
error="$error$tmp"
fi
if [ "$time" = "" ]; then
tmp=`cat "$benchmark_data"`
error="$error$tmp"
fi
if [ "$file" = "" ]; then
tmp=`cat "$benchmark_data"`
error="$error$tmp"
fi
if [ "$error" != "" ]; then
echo -e "$fw\n$error" >> "$error_file"
echo "---" >> "$error_file"
Expand Down
40 changes: 30 additions & 10 deletions benchmarks/hello_world.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
#!/bin/sh

# exit on failure - use during development
#set -e

cd `dirname $0`
. ./_functions.sh

base="$1"
stack="$1"
bm_name=`basename $0 .sh`

results_file="output/results.$bm_name.log"
check_file="output/check.$bm_name.log"
error_file="output/error.$bm_name.log"
url_file="output/urls.log"
if [ "$stack" = "local" ]; then
base="http://127.0.0.1/php-framework-benchmark"
fi
if [ "$stack" = "docker_nginx_php_5_6_4" ]; then
base="http://nginx_php_5_6_4"
fi
if [ "$stack" = "docker_nginx_hhvm_3_10_1" ]; then
base="http://nginx_hhvm_3_10_1"
fi
if [ "$stack" = "docker_nginx_php_7_0_0" ]; then
base="http://nginx_php_7_0_0"
fi

output_dir="output/$stack"

results_file="$output_dir/results.$bm_name.log"
check_file="$output_dir/check.$bm_name.log"
error_file="$output_dir/error.$bm_name.log"
url_file="$output_dir/urls.log"

cd ..

mv "$results_file" "$results_file.old"
mv "$check_file" "$check_file.old"
mv "$error_file" "$error_file.old"
mv "$url_file" "$url_file.old"
mkdir -p "$output_dir"

mv "$results_file" "$results_file.old" || true
mv "$check_file" "$check_file.old" || true
mv "$error_file" "$error_file.old" || true
mv "$url_file" "$url_file.old" || true

for fw in `echo $targets`
do
Expand All @@ -27,4 +47,4 @@ do
fi
done

cat "$error_file"
cat "$error_file" || true
12 changes: 12 additions & 0 deletions bin/docker-urls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

DIR=`dirname $0`;

echo "PHP 5.6.4 Stack:";
echo "http://"$(docker-machine ip default)":"$(docker-compose -f $DIR/../docker/docker-compose.yml port nginx_php_5_6_4 80 | sed 's/[0-9.]*://')
echo "HHVM 3.10.1 Stack:";
echo "http://"$(docker-machine ip default)":"$(docker-compose -f $DIR/../docker/docker-compose.yml port nginx_hhvm_3_10_1 80 | sed 's/[0-9.]*://')
echo "PHP 7.0.0 Stack:";
echo "http://"$(docker-machine ip default)":"$(docker-compose -f $DIR/../docker/docker-compose.yml port nginx_php_7_0_0 80 | sed 's/[0-9.]*://')

exit 0
7 changes: 5 additions & 2 deletions bin/show_comparison_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
require __DIR__ . '/../libs/build_table.php';
require __DIR__ . '/../libs/recalc_relative.php';

$stack = getenv('stack') ? getenv('stack') : 'local';
$output_dir = __DIR__ . '/../output/' . $stack;

$list = [
'cake-3.0',
'symfony-2.6',
'zf-2.4',
];

system('git checkout master');
$results_master = parse_results(__DIR__ . '/../output/results.hello_world.log');
$results_master = parse_results($output_dir . '/results.hello_world.log');
system('git checkout optimize');
$results_optimize = parse_results(__DIR__ . '/../output/results.hello_world.log');
$results_optimize = parse_results($output_dir . '/results.hello_world.log');
//var_dump($results_master, $results_optimize);

$is_fisrt = true;
Expand Down
5 changes: 4 additions & 1 deletion bin/show_results_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
require __DIR__ . '/../libs/parse_results.php';
require __DIR__ . '/../libs/build_table.php';

$results = parse_results(__DIR__ . '/../output/results.hello_world.log');
$stack = getenv('stack') ? getenv('stack') : 'local';
$output_dir = __DIR__ . '/../output/' . $stack;

$results = parse_results($output_dir . '/results.hello_world.log');
//var_dump($results);

echo build_table($results);
2 changes: 1 addition & 1 deletion cake-3.0/webroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
new Response()
);

require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
2 changes: 1 addition & 1 deletion cake-3.1/webroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
new Response()
);

require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
2 changes: 1 addition & 1 deletion ci-3.0/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@
*/
require_once BASEPATH.'core/CodeIgniter.php';

require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
2 changes: 1 addition & 1 deletion cygnite-1.3/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
*/
require_once CF_BOOTSTRAP.DS.'start'.EXT;

require $_SERVER['DOCUMENT_ROOT'].'/php-framework-benchmark/libs/output_data.php';
require getenv('php_framework_benchmark_path').'/libs/output_data.php';
64 changes: 64 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## Benchmarking using the supplied Docker Stack

Use the supplied Docker Stack in order to automatically set up the following benchmarking environments:

* Ubuntu 15.04 64bit (Docker)
* Nginx 1.7.12
* PHP-FPM 5.6.4
* Zend OPcache 7.0.4-dev
* PhalconPHP 2.0.9
* PHP-FPM 7.0.0
* Zend OPcache 7.0.6-dev
* PhalconPHP 2.0.9
* HHVM 3.10.1

By sharing underlying software stacks, the benchmark results vary only according to the host machine's hardware specs and differing code implementations.

### Getting Started

If running locally, install [Docker Toolbox](https://www.docker.com/docker-toolbox).

Clone the source code:
~~~
$ git clone https://github.com/kenjis/php-framework-benchmark.git
$ cd php-framework-benchmark
~~~

Cd into the docker directory of this repo and make sure that docker toolbox is available:
~~~
$ cd docker
$ eval "$(docker-machine env default)"
~~~

Start the Nginx/PHP server stacks:
~~~
$ docker-compose up -d
~~~

Start the supplied docker shell from within this repository's `docker` folder:
~~~
$ docker-compose run shell
~~~

Run the set-up script:
~~~
# sh setup.sh
~~~

Run benchmarks against each stack:
~~~
$ stack=docker_nginx_php_5_6_4 sh benchmark.sh
$ stack=docker_nginx_hhvm_3_10_1 sh benchmark.sh
$ stack=docker_nginx_php_7_0_0 sh benchmark.sh
~~~

### Check the results

To see the results graph, run the following script from outside the docker shell, from the repository root:

~~~
$ bin/docker-urls.sh
~~~

It echoes URLs, which you should open up in your browser.

Loading