Skip to content

Commit f0065cc

Browse files
authored
Merge pull request #41 from myaaghubi/v2.2
V2.2
2 parents e710ff7 + 9836910 commit f0065cc

File tree

87 files changed

+152
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+152
-243
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test PHP benchmark
2+
on: [ push, pull_request ]
3+
4+
jobs:
5+
setup:
6+
name: Check PHP frameworks
7+
runs-on: ubuntu-22.04
8+
9+
steps:
10+
11+
- uses: actions/checkout@v3
12+
13+
- name: Install WRK
14+
run: sudo apt-get install wrk w3m
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: 8.2
20+
extensions: dom, curl, libxml, mbstring, zip, pcntl, ctype, iconv, intl
21+
coverage: none
22+
23+
- name: Install Apache mod_php
24+
run: |
25+
LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu
26+
sudo apt install libapache2-mod-php8.2
27+
sudo a2enmod php8.2 rewrite
28+
shell: bash
29+
30+
- name: Setup frameworks
31+
run: bash setup.sh
32+
33+
- name: Copy files to web root
34+
run: |
35+
sudo mkdir /var/www/html/PHP-Frameworks-Bench
36+
sudo cp -R ./* /var/www/html/PHP-Frameworks-Bench/
37+
sudo chown -R www-data:www-data /var/www/html
38+
39+
- name: Restart apache server
40+
run: sudo service apache2 restart
41+
42+
- name: Check frameworks
43+
run: bash check.sh
44+

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/output/
2-
vendor/
3-
#/*/code/
1+
/output/*
2+
vendor/

0

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.2.8

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PHP Frameworks Bench
2-
![GitHub release (latest by date)](https://img.shields.io/github/v/release/myaaghubi/PHP-Frameworks-Bench?color=purpol) ![GitHub](https://img.shields.io/github/license/myaaghubi/PHP-Frameworks-Bench?color=green)
2+
[![Test PHP benchmark](https://github.com/myaaghubi/PHP-Frameworks-Bench/actions/workflows/test.yml/badge.svg)](https://github.com/myaaghubi/PHP-Frameworks-Bench/actions/workflows/test.yml) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/myaaghubi/PHP-Frameworks-Bench?color=purpol) ![GitHub](https://img.shields.io/github/license/myaaghubi/PHP-Frameworks-Bench?color=green)
33

44
This project attempts to measure the minimum overhead (minimum bootstrap cost) of PHP frameworks in the real world.
55

@@ -56,18 +56,16 @@ These are my benchmarks, not yours. **I encourage you to run on your (production
5656
|phroute-2.2 | 4,303.07| 44.4| 0.58| 1.4|
5757
|leaf-3.3 | 1,576.68| 16.3| 1.10| 2.6|
5858
|fatfree-3.8.1 | 1,512.30| 15.6| 1.67| 4.0|
59-
|siler-1.7.9 | 1,416.80| 14.6| 1.17| 2.8|
60-
|slim-3.12 | 1,061.05| 10.9| 1.40| 3.3|
6159
|slim-4.11 | 805.51| 8.3| 1.57| 3.7|
6260
|ubiquity-2.4.x.dev | 726.70| 7.5| 1.64| 3.9|
6361
|silex-2.3 | 558.07| 5.8| 2.16| 5.1|
6462
|yii-2.0-basic | 508.32| 5.2| 2.57| 6.1|
6563
|fuelphp-1.9 | 450.65| 4.6| 2.51| 6.0|
6664
|lumen-10.0 | 352.94| 3.6| 3.49| 8.3|
6765
|codeigniter-4.3 | 324.27| 3.3| 3.50| 8.3|
68-
|symfony-5.4 | 319.55| 3.3| 3.82| 9.1|
69-
|symfony-6.2 | 314.21| 3.2| 3.89| 9.2|
66+
|symfony-5.4 | 311.74| 3.2| 3.82| 9.1|
7067
|laminas-2.0 | 309.30| 3.2| 3.50| 8.3|
68+
|symfony-6.3 | 290.69| 3.0| 3.91| 9.3|
7169
|cakephp-4.4 | 262.25| 2.7| 4.49| 10.7|
7270
|laravel-10.0 | 96.97| 1.0| 11.99| 28.5|
7371

@@ -181,15 +179,13 @@ For frameworks, I considered the official repos:
181179
* [CodeIgniter](https://github.com/codeigniter4/CodeIgniter4)
182180
* [FastRoute](https://github.com/nikic/FastRoute)
183181
* [FatFree](https://github.com/bcosca/fatfree)
184-
* [FrameworkX](https://github.com/clue/framework-x)
185182
* [FuelPHP](https://github.com/fuelphp/fuelphp)
186183
* [KumbiaPHP](https://github.com/KumbiaPHP/KumbiaPHP)
187184
* [Laminas](https://github.com/laminas)
188185
* [Laravel](https://github.com/laravel/laravel)
189186
* [Leaf](https://github.com/leafsphp/leaf)
190187
* [Lumen](https://github.com/laravel/lumen)
191188
* [PhRoute](https://github.com/mrjgreen/phroute)
192-
* [Siler](https://github.com/leocavalcante/siler)
193189
* [Silex](https://github.com/silexphp/Silex)
194190
* [Slim](https://github.com/slimphp/Slim)
195191
* [Symfony](https://github.com/symfony/symfony)

base/_functions.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ benchmark () {
88
url_status=$(bash check.sh -t "$fw")
99

1010
# find 'done'
11-
status=${url_status%%done*}
11+
status=${url_status%%${fw}*}
1212

1313
# if the index of 'done' be equal to
1414
# the length of the url_status then
@@ -90,6 +90,4 @@ benchmark () {
9090
fi
9191

9292
echo "$url" >> "$url_file"
93-
94-
echo
9593
}

base/hello_world.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ if [ -f "$url_file" ]; then
3333
mv "$url_file" "$url_file.old"
3434
fi
3535

36-
37-
phpv=`php -r 'echo phpversion();'`
38-
echo "/------- PHP $phpv -------/"
36+
phpc=`curl -s "$base/libs/php_config.php"`
37+
echo "/------- PHP Config -------/"
38+
echo "$phpc"
3939

4040
for fw in `echo $param_targets`
4141
do
4242
if [ -d "$fw" ]; then
43-
echo "/------- $fw -------/"
43+
echo "\n/------- $fw -------/"
4444

4545
# read -p "Continue to $fw (y/n)?" choice
4646
# case "$choice" in
@@ -54,7 +54,7 @@ do
5454

5555
if [ "$param_clean" = true ]; then
5656
bash clean.sh
57-
bash setup.sh "$fw"
57+
bash setup.sh -t "$fw"
5858
fi
5959

6060
# read -p "Continue to benchmark (y/n)?" choice
@@ -67,7 +67,8 @@ do
6767
# fi
6868

6969
# reset the opcache
70-
php ./libs/reset_opcache.php
70+
opcacherest=`curl -s "$base/libs/reset_opcache.php"`
71+
echo "$opcacherest"
7172

7273
if [ "$param_restart_apache" = true ]; then
7374
echo 'systemctl restart apache2'

benchmark.config

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,18 @@ cakephp-4.4
2020
codeigniter-4.3
2121
fastroute-1.3
2222
fatfree-3.8.1
23-
frameworkx-dev
2423
fuelphp-1.9
25-
kumbiaphp-1.1
24+
kumbia-1.1
2625
laminas-2.0
2726
laravel-10.0
2827
leaf-3.3
2928
lumen-10.0
3029
phroute-2.2
3130
pure-php
32-
siler-1.7.9
3331
silex-2.3
34-
slim-3.12
3532
slim-4.11
3633
symfony-5.4
37-
symfony-6.2
34+
symfony-6.3
3835
ubiquity-2.4.x.dev
3936
yii-2.0-basic
40-
"
37+
"

benchmark.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ done
8181

8282
sh ./base/hello_world.sh
8383

84+
echo ''
8485
php ./libs/show_results_table.php

check.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,36 @@
33
. ./benchmark.config
44
. ./base/option_target.sh
55

6+
# Colors
7+
GREEN='\033[0;32m'
8+
RED='\033[0;31m'
9+
NC='\033[0m' # No Color
10+
11+
FAIL=0
12+
613
for fw in `echo $param_targets`
714
do
815
if [ -d "$fw" ]; then
9-
echo -n "/------- $fw: checking... "
1016
. "$fw/_benchmark/hello_world.sh"
1117

1218
url_output=$(curl -s "$url")
1319

1420
# expected to get the Hello World! + libs/output_data.php
1521
if ! [[ "$url_output" =~ ^('Hello World!')(.*)(([0-9]*):(([0-9]+([.][0-9]*)?|[.][0-9]+)):([0-9]*))$ ]]; then
16-
echo -e "error: \n$url"
17-
echo "$url_output"
22+
echo -e "${RED}$fw ${NC}"
23+
echo "$url"
24+
25+
if [ -x "$(command -v w3m)" ]; then
26+
echo "$url_output" | w3m -dump -T text/html
27+
else
28+
echo "$url_output"
29+
fi
30+
31+
FAIL=1
1832
else
19-
echo "done."
33+
printf "%-34b %4s bytes %s\n" "${GREEN}$fw ${NC}" "${#url_output}" "$url"
2034
fi
2135
fi
22-
done
36+
done
37+
38+
exit $FAIL
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
# clear cache
3-
sudo rm -rf writable/cache/*
3+
rm -rf writable/cache/*
44
echo -e "done"

0 commit comments

Comments
 (0)