Skip to content

Commit 00182fa

Browse files
authored
Merge pull request #5 from myaghobi/1.5
v1.5
2 parents 6d1a772 + 5ae124b commit 00182fa

15 files changed

+98
-89
lines changed

README.md

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,61 @@ Components like Template engines or ORM/Database libraries are out of scope in t
1313

1414

1515
- [PHP Frameworks Bench](#php-frameworks-bench)
16+
- [Benchmarks](#benchmarks)
17+
- [Latest](#latest)
1618
- [Benchmarking Policy](#benchmarking-policy)
1719
- [How to Benchmark](#how-to-benchmark)
1820
- [Commands](#commands)
19-
- [Benchmarks](#benchmarks)
20-
- [Latest](#latest)
21-
- [OPCache](#results-with-opcache)
2221
- [References](#references)
2322
- [License](#license)
2423

2524

25+
## Benchmarks
26+
27+
### Latest
28+
29+
#### Environment
30+
31+
* Ubuntu 22.04 LTS 64bit
32+
* PHP 8.1.6
33+
* OPCache enabled
34+
* Apache 2.4.52
35+
* CPU Core i7 2600K@4Ghz
36+
* Memory 16G
37+
38+
39+
#### Results (2022/5/22)
40+
41+
These are my benchmarks, not yours. **I encourage you to run on your (production equivalent) environments.**
42+
43+
![Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png)
44+
![Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png)
45+
![Benchmark Results Graph Execution Time](screenshots/php-frameworks-bench-exectime.png)
46+
![Benchmark Results Graph Included Files](screenshots/php-frameworks-bench-includedfiles.png)
47+
48+
|framework |requests per second|relative|peak memory|relative|
49+
|-------------------|------------------:|-------:|----------:|-------:|
50+
|pure-php | 42,114.24| 52.1| 0.34| 1.0|
51+
|phroute-2.2 | 33,424.47| 42.4| 0.34| 1.0|
52+
|fastroute-1.3 | 33,190.14| 42.1| 0.34| 1.0|
53+
|siler-1.7.9 | 22,152.74| 28.8| 0.36| 1.1|
54+
|leaf-3.0 | 20,685.10| 26.3| 0.36| 1.1|
55+
|fatfree-3.8.0 | 19,282.52| 24.5| 0.39| 1.1|
56+
|frameworkx-dev | 18,033.22| 22.9| 0.37| 1.1|
57+
|slim-4.10 | 14,958.27| 19.0| 0.38| 1.1|
58+
|slim-3.12 | 14,714.84| 18.7| 0.39| 1.1|
59+
|yii-2.0-basic | 11,831.91| 15.0| 0.70| 2.1|
60+
|ubiquity-2.4.x.dev | 11,669.47| 14.8| 0.38| 1.1|
61+
|silex-2.3 | 10,415.74| 13.2| 0.39| 1.1|
62+
|symfony-5.4 | 9,761.44| 12.4| 0.46| 1.4|
63+
|symfony-6.0 | 9,737.48| 12.4| 0.45| 1.3|
64+
|lumen-9.0 | 6,205.79| 7.7| 0.39| 1.1|
65+
|cakephp-4.3 | 5,562.91| 7.0| 0.43| 1.3|
66+
|laminas-2.0.x.dev | 5,015.71| 6.4| 0.49| 1.4|
67+
|fuelphp-1.9 | 4,894.22| 6.2| 0.45| 1.3|
68+
|codeigniter-4.1 | 1,938.43| 2.5| 1.46| 4.3|
69+
|laravel-9.1 | 788.76| 1.0| 0.55| 1.6|
70+
2671

2772
## Benchmarking Policy
2873

@@ -47,24 +92,26 @@ If you want to benchmark PHP extension frameworks like Phalcon, you need to inst
4792

4893
1- Download & install the library in your localhost:
4994

50-
```
51-
# instead you can use --branch vx.x
95+
```bash
96+
# you can put --branch vx.x
5297
$ git clone https://github.com/myaghobi/php-frameworks-bench.git
98+
5399
$ cd php-frameworks-bench
100+
54101
# run the setup & follow the progress
55102
$ bash setup.sh
56103
```
57104

58105
2- To make sure everything is ok:
59106

60-
```
107+
```bash
61108
# this is optional
62109
$ bash check.sh
63110
```
64111

65112
3- Run benchmarks:
66113

67-
```
114+
```bash
68115
$ bash benchmark.sh
69116
```
70117

@@ -75,7 +122,7 @@ $ bash benchmark.sh
75122

76123
## Commands
77124

78-
```
125+
```bash
79126
# composer update for each framework
80127
$ bash update.sh
81128

@@ -93,64 +140,12 @@ $ bash show-table.sh
93140

94141
To specify the frameworks, put them after each command:
95142

96-
```
143+
```bash
97144
$ bash benchmark.sh laravel-9.1/ slim-4.10/ fatfree-3.8.0/
98145
...
99146
```
100147

101148

102-
## Benchmarks
103-
104-
### Latest
105-
106-
#### Environment
107-
108-
* Ubuntu 22.04 LTS 64bit
109-
* PHP 8.1.5
110-
* OPCache disabled
111-
* Apache 2.4.52
112-
* CPU Core i7 2600K@4Ghz
113-
* Memory 16G
114-
115-
116-
#### Results (2022/5/15)
117-
118-
These are my benchmarks, not yours. **I encourage you to run on your (production equivalent) environments.**
119-
120-
![Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png)
121-
![Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png)
122-
![Benchmark Results Graph Execution Time](screenshots/php-frameworks-bench-exectime.png)
123-
![Benchmark Results Graph Included Files](screenshots/php-frameworks-bench-includedfiles.png)
124-
125-
|framework |requests per second|relative|peak memory|relative|
126-
|-------------------|------------------:|-------:|----------:|-------:|
127-
|pure-php | 22,427.34|22,427.3| 0.42| 0.4|
128-
|fastroute-1.3 | 4,224.76| 4,224.8| 0.56| 0.6|
129-
|phroute-2.2 | 3,901.59| 3,901.6| 0.58| 0.6|
130-
|leaf-3.0 | 1,539.38| 1,539.4| 1.05| 1.1|
131-
|fatfree-3.8.0 | 1,414.71| 1,414.7| 1.67| 1.7|
132-
|siler-1.7.9 | 1,314.15| 1,314.2| 1.17| 1.2|
133-
|frameworkx-dev | 972.97| 973.0| 1.41| 1.4|
134-
|slim-3.12 | 969.54| 969.5| 1.40| 1.4|
135-
|slim-4.10 | 752.96| 753.0| 1.60| 1.6|
136-
|yii-2.0-basic | 510.90| 510.9| 2.72| 2.7|
137-
|silex-2.3 | 510.51| 510.5| 2.18| 2.2|
138-
|fuelphp-1.9 | 410.60| 410.6| 2.50| 2.5|
139-
|ubiquity-2.4.x.dev | 379.51| 379.5| 2.33| 2.3|
140-
|lumen-9.0 | 329.70| 329.7| 3.39| 3.4|
141-
|symfony-6.0 | 293.11| 293.1| 3.85| 3.9|
142-
|symfony-5.4 | 291.41| 291.4| 3.77| 3.8|
143-
|codeigniter-4.1 | 290.94| 290.9| 3.39| 3.4|
144-
|laminas-2.0.x.dev | 284.43| 284.4| 3.52| 3.5|
145-
|cakephp-4.3 | 232.68| 232.7| 4.45| 4.5|
146-
|laravel-9.1 | 93.47| 93.5| 11.04| 11.0|
147-
148-
149-
150-
### Results with OPCache (old version)
151-
[![IMAGE ALT TEXT](http://img.youtube.com/vi/BUcxalvD92U/0.jpg)](http://www.youtube.com/watch?v=BUcxalvD92U "PHP OPCache Benchmarks, a Comparison for Popular Frameworks")
152-
153-
154149
## References
155150
Note: This project is based on
156151
[php-framework-benchmark](https://github.com/kenjis/php-framework-benchmark). It was very old and abandoned, so I decided to split it from the origin and update it separately.

benchmarks/_functions.sh renamed to base/_functions.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ benchmark () {
44
output_wrk="output/$fw.wrk.log"
55
output="output/$fw.output"
66

7-
url_output=$(curl -s "$url")
8-
reqsubstr="Hello World!"
9-
10-
# to make sure the appropriate response is reachable
11-
# otherwise, there is no point running the benchmark
12-
if ! [ -z "${url_output##*$reqsubstr*}" ] ;then
13-
tmp=`cat "$output"`
14-
error="$error$tmp"
15-
echo "error!"
16-
echo -e "$fw\n$error" >> "$error_file"
17-
echo "---" >> "$error_file"
18-
7+
# check out the appropriate response is reachable
8+
url_status=$(bash check.sh "$fw")
9+
10+
# find 'done'
11+
status=${url_status%%done*}
12+
13+
# if the index of 'done' be equal to
14+
# the length of the url_status then
15+
# the appropriate output (Hello World! ...) not reachable
16+
# and there is no point to run the benchmark
17+
if [ ${#status} -eq ${#url_status} ]; then
18+
echo "Error! $fw: Hello World! ... not reachable"
1919
echo "$fw: 0: 0: 0: 0" >> "$results_file"
2020
return 1
2121
fi
2222

23-
config_wrk="wrk -t50 -c1000 -d10s"
23+
config_wrk="wrk -t50 -c1000 -d60s"
2424

2525
# is it wsl!?
2626
# if you're using wsl, it's necessary to put -R (--rate)
@@ -53,10 +53,10 @@ benchmark () {
5353
do
5454
curl "$url" > "$output"
5555
t=`tail -1 "$output" | cut -f 2 -d ':'`
56-
total=`php ./benchmarks/sum_ms.php $t $total`
56+
total=`php ./base/sum_ms.php $t $total`
5757
i=$(( $i + 1 ))
5858
done
59-
time=`php ./benchmarks/avg_ms.php $total $count`
59+
time=`php ./base/avg_ms.php $total $count`
6060

6161

6262
# get memory and file
File renamed without changes.
File renamed without changes.
File renamed without changes.

benchmark.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
#!/bin/sh
22

3-
base="http://127.0.0.1/php-frameworks-bench"
3+
if [ ! `which wrk` ]; then
4+
echo "wrk not found."
5+
exit 1;
6+
fi
47

5-
# cd `dirname $0`#
8+
if [ ! `which curl` ]; then
9+
echo "curl not found."
10+
exit 1;
11+
fi
12+
13+
base="http://127.0.0.1/php-frameworks-bench"
614

715
if [ $# -eq 0 ]; then
8-
# include framework list
16+
# include frameworks list
917
. ./list.sh
1018
export targets="$list"
1119
else
1220
export targets="${@%/}"
1321
fi
1422

15-
cd benchmarks
23+
cd base
1624

1725
sh hello_world.sh "$base"
1826

check.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ do
2020

2121
url_output=$(curl -s "$url")
2222

23+
# expected to get the Hello World! + libs/output_data.php
2324
if ! [[ "$url_output" =~ ^('Hello World!')(.*)(([0-9]*):(([0-9]+([.][0-9]*)?|[.][0-9]+)):([0-9]*))$ ]]; then
2425
echo -e "error: \n$url"
2526
echo "$url_output"

clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [ $# -eq 0 ]; then
4-
# include framework list
4+
# include frameworks list
55
. ./list.sh
66
targets="$list"
77
else

clear-cache.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/sh
22

3+
if [ ! `which composer` ]; then
4+
echo "composer not found."
5+
exit 1;
6+
fi
7+
38
if [ $# -eq 0 ]; then
4-
# include framework list
9+
# include frameworks list
510
. ./list.sh
611
targets="$list"
712
else
1.62 KB
Loading

0 commit comments

Comments
 (0)