This is a very small script to show the execution time of dotenv loaders for 10000 executions with 1 iteration.
Every loader has to reach the same point, so opening the .env file, parsing it and loading the result into $_ENV and $_SERVER.
But feel free to make yours: edit docker-composer.yml command, revolutions=10000, iterations=1
version: '2'
services:
benchmark:
build:
context: ./
dockerfile: Dockerfile
command: php vendor/bin/phpbench run DotenvBench.php --report=aggregate --revs=10000 --iterations=1
# run the benchmark
docker-composer up --build
update composer.json for specific package version
"require": {
"josegonzalez/dotenv": "@dev",
"vlucas/phpdotenv": "@dev",
"rfussien/dotenv": "@dev",
"symfony/dotenv": "@dev",
"devcoder-xyz/php-dotenv": "@dev",
"phpbench/phpbench": "@dev"
}
- actual version: @dev
- 10.000 loops execution time: 149.284μs
- actual version: @dev
- 10.000 loops execution time: 400.453μs
- actual version: ~2.0
- 10.000 loops execution time: 85.049μs
- actual version: @dev
- 10.000 loops execution time: 141.451μs
- actual version: @dev
- 10.000 loops execution time: 46.604μs
- actual version: @dev
- 10.000 loops execution time: 36.270μs
| +-------------+-------------------+-----+-------+-----+----------+-----------+--------+
| | benchmark | subject | set | revs | its | mem_peak | mode | rstdev |
| +-------------+-------------------+-----+-------+-----+----------+-----------+--------+
| | DotenvBench | benchJosegonzalez | | 10000 | 1 | 39.390mb | 149.284μs | ±0.00% |
| | DotenvBench | benchVlucas@~2.0 | | 10000 | 1 | 1.027mb | 85.049μs | ±0.00% |
| | DotenvBench | benchVlucas@dev | | 10000 | 1 | 1.258mb | 403.774μs | ±0.00% |
| | DotenvBench | benchSymfony | | 10000 | 1 | 1.057mb | 144.216μs | ±0.00% |
| | DotenvBench | benchRfussien | | 10000 | 1 | 1.027mb | 49.428μs | ±0.00% |
| | DotenvBench | benchDevcoderxyz | | 10000 | 1 | 1.027mb | 39.376μs | ±0.00% |
| +-------------+-------------------+-----+-------+-----+----------+-----------+--------+