diff --git a/README.md b/README.md index 2e0a287..7733705 100755 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ For `PHP 8.2` check out [this link](https://github.com/myaaghubi/PHP-Frameworks- * Ubuntu 24.04 LTS x86_64 * PHP 8.4.3 - * OPCache Off + * OPCache Off ([Why Not??](https://github.com/myaaghubi/PHP-Frameworks-Bench/wiki/Why-not-OPcache-ON%3F%3F)) * Apache 2.4.58 * WRK 4.2.0 (5 min) * CPU Core i7-3770K/4.4Ghz @@ -49,6 +49,10 @@ For `PHP 8.2` check out [this link](https://github.com/myaaghubi/PHP-Frameworks- #### Results (2025/2/7) These are my benchmarks, not yours. **I encourage you to run on your -production equivalent- environments.** +```bash +# the command used for the results below +$ bash benchmark.sh -f -rapache +``` ![Frameworks Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png) ![Frameworks Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png) @@ -234,6 +238,7 @@ Note: This project is based on * [Laravel](https://github.com/laravel/laravel) * [Leaf](https://github.com/leafsphp/leaf) * [Lumen](https://github.com/laravel/lumen) +* [Nette](https://github.com/nette/web-project) * [PhRoute](https://github.com/mrjgreen/phroute) * [Silex](https://github.com/silexphp/Silex) * [Slim](https://github.com/slimphp/Slim) diff --git a/config b/config index d6dab72..f0391d9 100644 --- a/config +++ b/config @@ -25,9 +25,9 @@ laravel-10.3 laravel-11.0 leaf-3.11 lumen-10.0 +nette-3.3 phroute-2.2 pure-php -silex-2.3 slim-4.14 symfony-5.4 symfony-6.4 diff --git a/nette-3.3/_benchmark/clean.sh b/nette-3.3/_benchmark/clean.sh new file mode 100644 index 0000000..36d8cb0 --- /dev/null +++ b/nette-3.3/_benchmark/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh +rm -rf !("_benchmark") +find -path './.*' -delete +rm -rf _benchmark/temp \ No newline at end of file diff --git a/silex-2.3/_benchmark/clear-cache.sh b/nette-3.3/_benchmark/clear-cache.sh similarity index 63% rename from silex-2.3/_benchmark/clear-cache.sh rename to nette-3.3/_benchmark/clear-cache.sh index e629bde..b828c3c 100755 --- a/silex-2.3/_benchmark/clear-cache.sh +++ b/nette-3.3/_benchmark/clear-cache.sh @@ -1,3 +1,3 @@ #!/bin/sh # clear cache -echo -e "!" \ No newline at end of file +echo -e "done" \ No newline at end of file diff --git a/nette-3.3/_benchmark/hello_world.sh b/nette-3.3/_benchmark/hello_world.sh new file mode 100644 index 0000000..4924188 --- /dev/null +++ b/nette-3.3/_benchmark/hello_world.sh @@ -0,0 +1,2 @@ +#!/bin/sh +url="$base/$fw/www/index.php/hello/index" \ No newline at end of file diff --git a/nette-3.3/_benchmark/nette/app/Bootstrap.php b/nette-3.3/_benchmark/nette/app/Bootstrap.php new file mode 100644 index 0000000..9f1e2a4 --- /dev/null +++ b/nette-3.3/_benchmark/nette/app/Bootstrap.php @@ -0,0 +1,50 @@ +rootDir = dirname(__DIR__); + $this->configurator = new Configurator; + $this->configurator->setTempDirectory($this->rootDir . '/temp'); + } + + + public function bootWebApplication(): Nette\DI\Container + { + $this->initializeEnvironment(); + $this->setupContainer(); + return $this->configurator->createContainer(); + } + + + public function initializeEnvironment(): void + { + //$this->configurator->setDebugMode('secret@23.75.345.200'); // enable for your remote IP + $this->configurator->enableTracy($this->rootDir . '/log'); + + $this->configurator->createRobotLoader() + ->addDirectory(__DIR__) + ->register(); + } + + + private function setupContainer(): void + { + $configDir = $this->rootDir . '/config'; + $this->configurator->addConfig($configDir . '/common.neon'); + $this->configurator->addConfig($configDir . '/services.neon'); + } +} diff --git a/nette-3.3/_benchmark/nette/app/Core/RouterFactory.php b/nette-3.3/_benchmark/nette/app/Core/RouterFactory.php new file mode 100644 index 0000000..e04663b --- /dev/null +++ b/nette-3.3/_benchmark/nette/app/Core/RouterFactory.php @@ -0,0 +1,29 @@ +withPath('index.php') + ->addRoute('hello/index', function () { + echo 'Hello World!'; + }); + + return $router; + } +} diff --git a/nette-3.3/_benchmark/nette/config/common.neon b/nette-3.3/_benchmark/nette/config/common.neon new file mode 100644 index 0000000..16ebd63 --- /dev/null +++ b/nette-3.3/_benchmark/nette/config/common.neon @@ -0,0 +1,33 @@ +# see https://doc.nette.org/en/configuring + +parameters: + + +application: + mapping: App\Presentation\*\**Presenter + + +database: + dsn: 'sqlite::memory:' + user: + password: + + +latte: + strictTypes: yes + strictParsing: yes + extensions: + - App\Presentation\Accessory\LatteExtension + + +assets: + mapping: + default: + path: assets + # type: vite # Uncomment to activate Vite for asset building + + +di: + export: + parameters: no + tags: no diff --git a/nette-3.3/_benchmark/nette/config/services.neon b/nette-3.3/_benchmark/nette/config/services.neon new file mode 100644 index 0000000..67302ee --- /dev/null +++ b/nette-3.3/_benchmark/nette/config/services.neon @@ -0,0 +1,11 @@ +services: + - App\Core\RouterFactory::createRouter + + +search: + - in: %appDir% + classes: + - *Facade + - *Factory + - *Repository + - *Service diff --git a/nette-3.3/_benchmark/nette/www/index.php b/nette-3.3/_benchmark/nette/www/index.php new file mode 100644 index 0000000..ef4b7dd --- /dev/null +++ b/nette-3.3/_benchmark/nette/www/index.php @@ -0,0 +1,13 @@ +bootWebApplication(); +$application = $container->getByType(Nette\Application\Application::class); +$application->run(); + +/* *** PHP-Frameworks-Bench *** */ +require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; diff --git a/nette-3.3/_benchmark/setup.sh b/nette-3.3/_benchmark/setup.sh new file mode 100755 index 0000000..71a2653 --- /dev/null +++ b/nette-3.3/_benchmark/setup.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# create project +rm -rf _benchmark/temp +composer create-project nette/web-project:3.3.* ./_benchmark/temp --ansi +mv ./_benchmark/temp/* ./ + +# override the route & controller +yes|cp -r _benchmark/nette/* ./ + +# some enhancement +composer install --no-dev --optimize-autoloader --ansi +chmod -R o+w log temp \ No newline at end of file diff --git a/nette-3.3/_benchmark/update.sh b/nette-3.3/_benchmark/update.sh new file mode 100644 index 0000000..77d0e12 --- /dev/null +++ b/nette-3.3/_benchmark/update.sh @@ -0,0 +1,9 @@ +#!/bin/sh +composer update + +# override the route & controller +yes|cp -r _benchmark/nette/* ./ + +# some enhancements +composer install --no-dev --optimize-autoloader +chmod -R o+w log temp \ No newline at end of file diff --git a/silex-2.3/Controllers/HelloWorldController.php b/silex-2.3/Controllers/HelloWorldController.php deleted file mode 100755 index a82613d..0000000 --- a/silex-2.3/Controllers/HelloWorldController.php +++ /dev/null @@ -1,13 +0,0 @@ -get('/hello/index', 'Controllers\HelloWorldController::getIndex'); - -$app->run(); - -/* *** PHP-Frameworks-Bench *** */ -require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php';