public
Last active

  • Download Gist
00-readme.md
Markdown

php micro frameworks benchmarks

frameworks used

Slim will be added later.

php setup & modules

PHP version used is 5.5.8 with the following extensions enabled:

  • zend opcache
  • apcu

server

The app scripts were served using the PHP built-in web server.

php -S 0.0.0.0:8000 -t . <script-name>.php

test machine specs

  • 1.7 GHz Intel Core i5
  • 4GB 1333 MHz DDR3 RAM
  • OS X Mavericks 1.9.1

method

Each benchmark is run using apache bench.

ab -n 1000 -c 50 <url>

Each benchmark is tried 3 times, then the highest scores are used.

dispatch-app.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
require __DIR__."/vendor/autoload.php";
 
// create some dummy routes for lookup perf
for ($i = 1, $fake_routes = 20; $i <= $fake_routes; ++$i) {
on('GET', "/greet/:name/{$i}", function ($name) {
echo "ok\n";
});
}
 
// last route is our target
on('GET', '/greet/:name', function ($name) {
echo "ok\n";
});
 
dispatch();
?>
dispatch-bench.txt
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
$ ab -n 1000 -c 50 http://127.0.0.1:8000/greet/stranger
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
 
 
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8000
 
Document Path: /greet/stranger
Document Length: 3 bytes
 
Concurrency Level: 50
Time taken for tests: 0.479 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 113000 bytes
HTML transferred: 3000 bytes
Requests per second: 2086.99 [#/sec] (mean)
Time per request: 23.958 [ms] (mean)
Time per request: 0.479 [ms] (mean, across all concurrent requests)
Transfer rate: 230.30 [Kbytes/sec] received
 
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 3
Processing: 1 23 3.6 24 32
Waiting: 1 23 3.6 23 32
Total: 3 23 3.4 24 32
 
Percentage of the requests served within a certain time (ms)
50% 24
66% 24
75% 25
80% 25
90% 26
95% 30
98% 31
99% 32
100% 32 (longest request)
klein-app.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
require __DIR__.'/vendor/autoload.php';
 
$app = new \Klein\Klein();
 
// create some dummy routes for lookup perf
for ($i = 1, $fake_routes = 20; $i <= $fake_routes; ++$i) {
$app->respond('GET', "/greet/[:name]/{$i}", function ($req, $res) {
return "ok\n";
});
}
 
// last route is our target
$app->respond('GET', '/greet/[:name]', function () {
return "ok\n";
});
 
$app->dispatch();
?>
klein-bench.txt
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
$ ab -n 1000 -c 50 http://127.0.0.1:8000/greet/stranger
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
 
 
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8000
 
Document Path: /greet/stranger
Document Length: 3 bytes
 
Concurrency Level: 50
Time taken for tests: 1.100 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 113000 bytes
HTML transferred: 3000 bytes
Requests per second: 909.08 [#/sec] (mean)
Time per request: 55.000 [ms] (mean)
Time per request: 1.100 [ms] (mean, across all concurrent requests)
Transfer rate: 100.32 [Kbytes/sec] received
 
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 3
Processing: 3 53 6.3 54 67
Waiting: 3 53 6.3 54 67
Total: 6 54 6.0 54 68
 
Percentage of the requests served within a certain time (ms)
50% 54
66% 55
75% 56
80% 57
90% 58
95% 59
98% 61
99% 64
100% 68 (longest request)
silex-app.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
require __DIR__.'/vendor/autoload.php';
 
$app = new Silex\Application();
 
for ($i = 1, $fake_routes = 20; $i <= $fake_routes; ++$i) {
$app->get("/greet/{name}/{$i}", function ($name) {
return "ok\n";
});
}
 
$app->get('/greet/{name}', function ($name) {
return "ok\n";
});
 
$app->run();
?>
silex-bench.txt
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
$ ab -n 1000 -c 50 http://127.0.0.1:8000/greet/stranger
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
 
 
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8000
 
Document Path: /greet/stranger
Document Length: 3 bytes
 
Concurrency Level: 50
Time taken for tests: 4.103 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 237000 bytes
HTML transferred: 3000 bytes
Requests per second: 243.70 [#/sec] (mean)
Time per request: 205.166 [ms] (mean)
Time per request: 4.103 [ms] (mean, across all concurrent requests)
Transfer rate: 56.40 [Kbytes/sec] received
 
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 3
Processing: 5 200 23.3 204 220
Waiting: 5 200 23.3 204 220
Total: 9 200 22.9 204 220
 
Percentage of the requests served within a certain time (ms)
50% 204
66% 206
75% 207
80% 208
90% 209
95% 211
98% 213
99% 214
100% 220 (longest request)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.