Skip to content

Commit 9713999

Browse files
committed
Update README.md
1 parent 71babab commit 9713999

File tree

1 file changed

+64
-32
lines changed

1 file changed

+64
-32
lines changed

README.md

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PHP Frameworks Bench
22
[![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

4+
45
This project attempts to measure the minimum overhead (minimum bootstrap cost) of PHP frameworks in the real world.
56

67
So I think the minimum should not include:
@@ -16,9 +17,11 @@ Benchmarking on components like template engines or ORM/Database libraries is ou
1617
- [Benchmarks](#benchmarks)
1718
- [Latest](#latest)
1819
- [OPCache On/Off](#opcache-on)
19-
- [Benchmarking Policy](#benchmarking-policy)
2020
- [How to Benchmark](#how-to-benchmark)
21+
- [Docker](#docker)
2122
- [Commands](#commands)
23+
- [Benchmarking Policy](#benchmarking-policy)
24+
- [Add Your Framework](#add-your-framework)
2225
- [Donate](#-donate)
2326
- [References](#references)
2427
- [License](#license)
@@ -41,12 +44,12 @@ Benchmarking on components like template engines or ORM/Database libraries is ou
4144

4245
#### Results (2023/5/15)
4346

44-
These are my benchmarks, not yours. **I encourage you to run on your (production equivalent) environments.**
47+
These are my benchmarks, not yours. **I encourage you to run on your -production equivalent- environments.**
4548

46-
![Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png)
47-
![Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png)
48-
![Benchmark Results Graph Execution Time](screenshots/php-frameworks-bench-exectime.png)
49-
![Benchmark Results Graph Included Files](screenshots/php-frameworks-bench-includedfiles.png)
49+
![Frameworks Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png)
50+
![Frameworks Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png)
51+
![Frameworks Benchmark Results Graph Execution Time](screenshots/php-frameworks-bench-exectime.png)
52+
![Frameworks Benchmark Results Graph Included Files](screenshots/php-frameworks-bench-includedfiles.png)
5053

5154
|framework |requests per second (rps)|relative (rps)|peak memory|relative (mem)|
5255
|-------------------|------------------------:|-------------:|----------:|-------------:|
@@ -71,29 +74,13 @@ These are my benchmarks, not yours. **I encourage you to run on your (production
7174

7275

7376
#### OPCache On
77+
Check out the video for more information.
7478
[![Results with OPCache On/Off & How to add your framework](http://img.youtube.com/vi/Dk8YHQZ6jfY/0.jpg)](http://www.youtube.com/watch?v=Dk8YHQZ6jfY)
7579

7680

77-
## Benchmarking Policy
78-
79-
This is for the `main` branch.
80-
81-
* Frameworks installed via `composer` according to their official documentation.
82-
* Used the default configuration.
83-
* Considering the minimum changes on frameworks to run the benchmark.
84-
* Didn't remove any components/configurations even if there is no use for them.
85-
* We have a `controller` class to get the `Hello World` for each, based on the default template of each framework.
86-
* Turned off the `debug` mode and set the environment to `production` mode.
87-
* Considered general optimization for the production environment, like `--optimize-autoloader` for the composer.
88-
89-
Some frameworks are optimized more than others, so some people may think using default configuration is not fair. The dept of optimizing a framework depends on the experiences of the developer too, so it's the rabbit hole and there is no point in it. I think the default configuration of frameworks is a good starting point to get ranking.
90-
91-
If you find something wrong in my code, feel free to send a PR. But please note optimizing for the "Hello World" is not acceptable! Building the fastest `Hello World` application is not the goal of this project.
92-
93-
9481
## How to Benchmark
9582

96-
If you want to have benchmarks on `PHP extension frameworks` like `Phalcon`, you need to install the extension first based on its own documentation.
83+
If you want to have benchmarks on `PHP extension frameworks` like `Phalcon`, you need to install the extension first, based on its own documentation.
9784

9885
1- Download & Setup:
9986

@@ -115,32 +102,58 @@ $ yes | bash setup.sh
115102
```bash
116103
$ bash check.sh
117104
# bash check.sh -t pure-php
118-
# /------- pure-php: checking... done.
105+
# pure-php
119106
```
120107

121108
3- Run benchmarks:
122109

123110
```bash
111+
# bash benchmark.sh --help
124112
$ bash benchmark.sh
125113
```
126114

127115
4- Check the results:
128116
- web:
129117

130-
<http://localhost/PHP-Frameworks-Bench/>
118+
<http://127.0.0.1/PHP-Frameworks-Bench/>
131119

132120
- terminal:
133-
```
121+
```bash
122+
# bash results.sh --help
134123
bash results.sh
135124
```
136125

137126

127+
## Docker
128+
129+
Results with docker may not be reliable but in a situation you can use it like:
130+
131+
1- Change the `base` in `benchmark.config` on the right port(`8080` considered):
132+
133+
```ini
134+
base="http://127.0.0.1:8080/PHP-Frameworks-Bench"
135+
...
136+
```
137+
138+
2- Run/download the docker:
139+
140+
```bash
141+
$ bash docker-apache.sh
142+
```
143+
144+
3- Run the benchmark:
145+
146+
```bash
147+
# run it in another terminal
148+
$ bash benchmark.sh
149+
```
150+
151+
138152
## Commands
139153

140154
```bash
141-
# some options
142155
# use bash benchmark.sh --help
143-
$ bash benchmark.sh -f -rapache -rnginx -t ...
156+
$ bash benchmark.sh -f -rapache -t pure-php
144157

145158
# run composer update for frameworks
146159
$ bash update.sh
@@ -153,28 +166,47 @@ $ bash clean.sh
153166
# clear the cache of frameworks
154167
$ bash clear-cache.sh
155168

156-
# show the results of the last benchmark
169+
# show the results table
157170
$ bash results.sh
158171
```
159172

160173
To specify frameworks, put them with `-t ...` after each command:
161174

162175
```bash
163176
# supported for `setup.sh`, `benchmark.sh`, `update.sh`, `clean.sh`, and `clear-cache.sh`
164-
# not required to put / after the name, just use the tab in your terminal
165-
# bash benchmarks.sh --help -h
177+
# bash benchmarks.sh --help
166178
$ bash benchmark.sh -t laravel-10.0/ slim-4.11/ ...
167179
...
168180
```
169181

170182

183+
## Add Your Framework
184+
Check out the [Benchmarking Policy](#benchmarking-policy), to get more information watch the video [OPCache On/Off](#opcache-on).
185+
186+
187+
## Benchmarking Policy
188+
189+
* Use `composer` to install frameworks according to their official documentation.
190+
* Use the default configuration.
191+
* Minimum changes on frameworks to have benchmarks.
192+
* Don't remove any components/configurations even if there is no use for them.
193+
* Include a `controller` class to get the `Hello World!` for each, based on the default template of each framework for `controllers`.
194+
* Turn off the `debug` mode and set the environment to `production` mode.
195+
* General optimization for the production environment, like `--optimize-autoloader` for the `composer`.
196+
197+
Some frameworks are optimized more than others, so some developers may think using default configuration is not fair. The dept of optimizing a framework depends on the skills/experiences of the developer too, so it's the rabbit hole and nonsense for ranking. Please **note** optimizing for the `Hello World` is not acceptable! Building the fastest `Hello World` application is not the goal of this project. I think the default configuration of frameworks is a good starting point to have a ranking.
198+
199+
If you find something wrong in my code, feel free to send a `PR`.
200+
201+
171202
## 🍔 Donate
172203
Don't forget to donate if you find it useful ☕ 🍺 🍸 🍔
173204

174205
ETH: 0x0ADd51D6855d2DF11BB5F331A3fa345c67a863b2
175206

176207
![Ethereum](screenshots/ethereum.jpg?raw=true "Ethereum")
177208

209+
178210
## References
179211
Note: This project is based on
180212
[php-framework-benchmark](https://github.com/kenjis/php-framework-benchmark), thanks to [Kenjis](https://github.com/kenjis). It is very old and abandoned, so I decided to split it from the origin and update it separately.

0 commit comments

Comments
 (0)