Parcourir la source

Create Hello world benchmark

tags/4.2.2.1
Steevan BARBOYON il y a 7 ans
Parent
révision
e744656389

+ 0
- 12
.env Voir le fichier

1
-# This file defines all environment variables that the application needs.
2
-# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE.
3
-# Use ".env.local" for local overrides during development.
4
-# Use real environment variables when deploying to production.
5
-# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
6
-
7
-###> symfony/framework-bundle ###
8
-APP_ENV=dev
9
-APP_SECRET=ad33d4d8b44231f5233cd8dfd8f355bc
10
-#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
11
-#TRUSTED_HOSTS=localhost,example.com
12
-###< symfony/framework-bundle ###

+ 3
- 0
.gitignore Voir le fichier

1
 .idea/
1
 .idea/
2
+composer.lock
3
+!var/cache/.gitkeep
4
+!var/log/.gitkeep
2
 
5
 
3
 ###> symfony/framework-bundle ###
6
 ###> symfony/framework-bundle ###
4
 /.env.local
7
 /.env.local

+ 27
- 0
README.md Voir le fichier

1
+<p align="center">
2
+  <img src="http://www.phpbenchmarks.com/images/logo_github.png">
3
+  <br>
4
+  <a href="http://www.phpbenchmarks.com" target="_blank">www.phpbenchmarks.com</a>
5
+</p>
6
+
7
+## What is www.phpbenchmarks.com ?
8
+
9
+You will find lot of benchmarks for PHP frameworks and template engines.
10
+
11
+You can compare results between Apache Bench and Siege, and PHP 5.6 to 7.2.
12
+
13
+## What is this repository ?
14
+
15
+It's benchmark common code for Symfony benchmarks.
16
+
17
+Switch branch to select your Symfony major version and benchmark you want to see.
18
+
19
+See all Symfony benchmarked versions on [phpbenchmarks/symfony](https://github.com/phpbenchmarks/symfony).
20
+
21
+You can find how we benchmark on [phpbenchmarks.com](http://www.phpbenchmarks.com/en/benchmark-protocol.html).
22
+
23
+## Benchmarks
24
+
25
+You can find all Symfony benchmarks results on [phpbenchmarks.com](http://www.phpbenchmarks.com/en/benchmark/symfony.html).
26
+
27
+Scores are too low ? Do not hesitate to create a pull request, and ask a new benchmark !

+ 1
- 23
bin/console Voir le fichier

4
 use App\Kernel;
4
 use App\Kernel;
5
 use Symfony\Bundle\FrameworkBundle\Console\Application;
5
 use Symfony\Bundle\FrameworkBundle\Console\Application;
6
 use Symfony\Component\Console\Input\ArgvInput;
6
 use Symfony\Component\Console\Input\ArgvInput;
7
-use Symfony\Component\Debug\Debug;
8
 
7
 
9
 set_time_limit(0);
8
 set_time_limit(0);
10
 
9
 
11
 require dirname(__DIR__).'/vendor/autoload.php';
10
 require dirname(__DIR__).'/vendor/autoload.php';
12
 
11
 
13
-if (!class_exists(Application::class)) {
14
-    throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
15
-}
16
-
17
 $input = new ArgvInput();
12
 $input = new ArgvInput();
18
-if (null !== $_ENV['APP_ENV'] = $input->getParameterOption(['--env', '-e'], null, true)) {
19
-    putenv('APP_ENV='.$_ENV['APP_ENV']);
20
-    // force loading .env files when --env is defined
21
-    $_SERVER['APP_ENV'] = null;
22
-}
23
-
24
-if ($input->hasParameterOption('--no-debug', true)) {
25
-    putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
26
-}
27
 
13
 
28
 require dirname(__DIR__).'/src/.bootstrap.php';
14
 require dirname(__DIR__).'/src/.bootstrap.php';
29
 
15
 
30
-if ($_SERVER['APP_DEBUG']) {
31
-    umask(0000);
32
-
33
-    if (class_exists(Debug::class)) {
34
-        Debug::enable();
35
-    }
36
-}
37
-
38
-$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
16
+$kernel = new Kernel('prod', false);
39
 $application = new Application($kernel);
17
 $application = new Application($kernel);
40
 $application->run($input);
18
 $application->run($input);

+ 4
- 10
composer.json Voir le fichier

1
 {
1
 {
2
-    "type": "project",
2
+    "name": "phpbenchmarks/symfony",
3
     "license": "proprietary",
3
     "license": "proprietary",
4
+    "type": "project",
4
     "minimum-stability": "dev",
5
     "minimum-stability": "dev",
5
     "require": {
6
     "require": {
6
         "php": "^7.1.3",
7
         "php": "^7.1.3",
9
         "symfony/console": "4.2.*",
10
         "symfony/console": "4.2.*",
10
         "symfony/flex": "^1.1",
11
         "symfony/flex": "^1.1",
11
         "symfony/framework-bundle": "4.2.*",
12
         "symfony/framework-bundle": "4.2.*",
12
-        "symfony/yaml": "4.2.*"
13
-    },
14
-    "require-dev": {
15
-        "symfony/dotenv": "4.2.*"
13
+        "symfony/yaml": "4.2.*",
14
+        "phpbenchmarks/symfony-common": "4.1.1"
16
     },
15
     },
17
     "config": {
16
     "config": {
18
         "preferred-install": {
17
         "preferred-install": {
25
             "App\\": "src/"
24
             "App\\": "src/"
26
         }
25
         }
27
     },
26
     },
28
-    "autoload-dev": {
29
-        "psr-4": {
30
-            "App\\Tests\\": "tests/"
31
-        }
32
-    },
33
     "replace": {
27
     "replace": {
34
         "paragonie/random_compat": "2.*",
28
         "paragonie/random_compat": "2.*",
35
         "symfony/polyfill-ctype": "*",
29
         "symfony/polyfill-ctype": "*",

composer.lock → composer.lock.php7.1 Voir le fichier

4
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
4
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
         "This file is @generated automatically"
5
         "This file is @generated automatically"
6
     ],
6
     ],
7
-    "content-hash": "7a44a356fe1a341196ca1980b05b7bb7",
7
+    "content-hash": "a5807e921f457dc7e29c4642a50617ed",
8
     "packages": [
8
     "packages": [
9
+        {
10
+            "name": "phpbenchmarks/symfony-common",
11
+            "version": "4.1.1",
12
+            "source": {
13
+                "type": "git",
14
+                "url": "https://github.com/phpbenchmarks/symfony-common.git",
15
+                "reference": "e110a58e75a071b77d529711185229379f165d00"
16
+            },
17
+            "dist": {
18
+                "type": "zip",
19
+                "url": "https://api.github.com/repos/phpbenchmarks/symfony-common/zipball/e110a58e75a071b77d529711185229379f165d00",
20
+                "reference": "e110a58e75a071b77d529711185229379f165d00",
21
+                "shasum": ""
22
+            },
23
+            "type": "project",
24
+            "autoload": {
25
+                "psr-4": {
26
+                    "PhpBenchmarksSymfony\\HelloWorldBundle\\": ""
27
+                }
28
+            },
29
+            "notification-url": "https://packagist.org/downloads/",
30
+            "license": [
31
+                "proprietary"
32
+            ],
33
+            "time": "2018-11-15T13:54:37+00:00"
34
+        },
9
         {
35
         {
10
             "name": "psr/cache",
36
             "name": "psr/cache",
11
             "version": "dev-master",
37
             "version": "dev-master",
1330
             "time": "2018-11-11T19:52:12+00:00"
1356
             "time": "2018-11-11T19:52:12+00:00"
1331
         }
1357
         }
1332
     ],
1358
     ],
1333
-    "packages-dev": [
1334
-        {
1335
-            "name": "symfony/dotenv",
1336
-            "version": "dev-master",
1337
-            "source": {
1338
-                "type": "git",
1339
-                "url": "https://github.com/symfony/dotenv.git",
1340
-                "reference": "64b5cde8384fd4e9ab98ce23613e2a6d56044796"
1341
-            },
1342
-            "dist": {
1343
-                "type": "zip",
1344
-                "url": "https://api.github.com/repos/symfony/dotenv/zipball/64b5cde8384fd4e9ab98ce23613e2a6d56044796",
1345
-                "reference": "64b5cde8384fd4e9ab98ce23613e2a6d56044796",
1346
-                "shasum": ""
1347
-            },
1348
-            "require": {
1349
-                "php": "^7.1.3"
1350
-            },
1351
-            "require-dev": {
1352
-                "symfony/process": "~3.4|~4.0"
1353
-            },
1354
-            "type": "library",
1355
-            "extra": {
1356
-                "branch-alias": {
1357
-                    "dev-master": "4.2-dev"
1358
-                }
1359
-            },
1360
-            "autoload": {
1361
-                "psr-4": {
1362
-                    "Symfony\\Component\\Dotenv\\": ""
1363
-                },
1364
-                "exclude-from-classmap": [
1365
-                    "/Tests/"
1366
-                ]
1367
-            },
1368
-            "notification-url": "https://packagist.org/downloads/",
1369
-            "license": [
1370
-                "MIT"
1371
-            ],
1372
-            "authors": [
1373
-                {
1374
-                    "name": "Fabien Potencier",
1375
-                    "email": "fabien@symfony.com"
1376
-                },
1377
-                {
1378
-                    "name": "Symfony Community",
1379
-                    "homepage": "https://symfony.com/contributors"
1380
-                }
1381
-            ],
1382
-            "description": "Registers environment variables from a .env file",
1383
-            "homepage": "https://symfony.com",
1384
-            "keywords": [
1385
-                "dotenv",
1386
-                "env",
1387
-                "environment"
1388
-            ],
1389
-            "time": "2018-11-13T19:27:38+00:00"
1390
-        }
1391
-    ],
1359
+    "packages-dev": [],
1392
     "aliases": [],
1360
     "aliases": [],
1393
     "minimum-stability": "dev",
1361
     "minimum-stability": "dev",
1394
     "stability-flags": [],
1362
     "stability-flags": [],

+ 1371
- 0
composer.lock.php7.2
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 1
- 0
config/bundles.php Voir le fichier

2
 
2
 
3
 return [
3
 return [
4
     Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
4
     Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5
+    PhpBenchmarksSymfony\HelloWorldBundle\HelloWorldBundle::class => ['all' => true]
5
 ];
6
 ];

+ 0
- 3
config/packages/dev/routing.yaml Voir le fichier

1
-framework:
2
-    router:
3
-        strict_requirements: true

+ 0
- 4
config/packages/test/framework.yaml Voir le fichier

1
-framework:
2
-    test: true
3
-    session:
4
-        storage_id: session.storage.mock_file

+ 0
- 3
config/packages/test/routing.yaml Voir le fichier

1
-framework:
2
-    router:
3
-        strict_requirements: true

+ 2
- 3
config/routes.yaml Voir le fichier

1
-#index:
2
-#    path: /
3
-#    controller: App\Controller\DefaultController::index
1
+helloworld:
2
+    resource: ../vendor/phpbenchmarks/symfony-common/Resources/config/routing.yml

+ 0
- 27
config/services.yaml Voir le fichier

1
-# This file is the entry point to configure your own services.
2
-# Files in the packages/ subdirectory configure your dependencies.
3
-
4
-# Put parameters here that don't need to change on each machine where the app is deployed
5
-# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
6
-parameters:
7
-
8
-services:
9
-    # default configuration for services in *this* file
10
-    _defaults:
11
-        autowire: true      # Automatically injects dependencies in your services.
12
-        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
13
-
14
-    # makes classes in src/ available to be used as services
15
-    # this creates a service per class whose id is the fully-qualified class name
16
-    App\:
17
-        resource: '../src/*'
18
-        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
19
-
20
-    # controllers are imported separately to make sure services can be injected
21
-    # as action arguments even if you don't extend any base controller class
22
-    App\Controller\:
23
-        resource: '../src/Controller'
24
-        tags: ['controller.service_arguments']
25
-
26
-    # add more service definitions when explicit configuration is needed
27
-    # please note that last definitions always *replace* previous ones

+ 26
- 0
init_benchmark.sh Voir le fichier

1
+#!/usr/bin/env bash
2
+
3
+function clearCacheAndLogs() {
4
+    sudo /bin/rm -rf var/cache/*
5
+    [ "$?" != "0" ] && exit 1
6
+    sudo /bin/chmod -R 777 var/cache
7
+    [ "$?" != "0" ] && exit 1
8
+
9
+    sudo /bin/rm -rf var/log/*
10
+    [ "$?" != "0" ] && exit 1
11
+    sudo /bin/chmod -R 777 var/log
12
+    [ "$?" != "0" ] && exit 1
13
+
14
+    php bin/console cache:warmup
15
+}
16
+
17
+function init() {
18
+    clearCacheAndLogs
19
+
20
+    composer install --no-dev --classmap-authoritative
21
+    [ "$?" != "0" ] && exit 1
22
+
23
+    clearCacheAndLogs
24
+
25
+    return 0
26
+}

+ 3
- 8
public/index.php Voir le fichier

1
 <?php
1
 <?php
2
 
2
 
3
 use App\Kernel;
3
 use App\Kernel;
4
-use Symfony\Component\Debug\Debug;
5
 use Symfony\Component\HttpFoundation\Request;
4
 use Symfony\Component\HttpFoundation\Request;
6
 
5
 
7
 require dirname(__DIR__).'/src/.bootstrap.php';
6
 require dirname(__DIR__).'/src/.bootstrap.php';
8
 
7
 
9
-if ($_SERVER['APP_DEBUG']) {
10
-    umask(0000);
11
-
12
-    Debug::enable();
13
-}
14
-
15
 if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
8
 if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
16
     Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
9
     Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
17
 }
10
 }
20
     Request::setTrustedHosts(explode(',', $trustedHosts));
13
     Request::setTrustedHosts(explode(',', $trustedHosts));
21
 }
14
 }
22
 
15
 
23
-$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
16
+$kernel = new Kernel('prod', false);
24
 $request = Request::createFromGlobals();
17
 $request = Request::createFromGlobals();
25
 $response = $kernel->handle($request);
18
 $response = $kernel->handle($request);
26
 $response->send();
19
 $response->send();
27
 $kernel->terminate($request, $response);
20
 $kernel->terminate($request, $response);
21
+
22
+// require phpbenchmarks stats.php here when needed

+ 2
- 17
src/.bootstrap.php Voir le fichier

1
 <?php
1
 <?php
2
 
2
 
3
-use Symfony\Component\Dotenv\Dotenv;
4
-
5
 require dirname(__DIR__).'/vendor/autoload.php';
3
 require dirname(__DIR__).'/vendor/autoload.php';
6
 
4
 
7
-if (!array_key_exists('APP_ENV', $_SERVER)) {
8
-    $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
9
-}
10
-
11
-if ('prod' !== $_SERVER['APP_ENV']) {
12
-    if (!class_exists(Dotenv::class)) {
13
-        throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
14
-    }
15
-
16
-    (new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
17
-}
18
-
19
-$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
20
-$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
21
-$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
5
+$_SERVER['APP_ENV'] = 'prod';
6
+$_SERVER['APP_DEBUG'] = false;

+ 6
- 0
symfony.lock Voir le fichier

1
 {
1
 {
2
+    "phpbenchmarks/symfony-common": {
3
+        "version": "4.1.0"
4
+    },
2
     "psr/cache": {
5
     "psr/cache": {
3
         "version": "1.0.x-dev"
6
         "version": "1.0.x-dev"
4
     },
7
     },
71
     "symfony/http-kernel": {
74
     "symfony/http-kernel": {
72
         "version": "4.2-dev"
75
         "version": "4.2-dev"
73
     },
76
     },
77
+    "symfony/lts": {
78
+        "version": "4-dev"
79
+    },
74
     "symfony/polyfill-mbstring": {
80
     "symfony/polyfill-mbstring": {
75
         "version": "v1.10.0"
81
         "version": "v1.10.0"
76
     },
82
     },

src/Controller/.gitignore → var/cache/.gitkeep Voir le fichier


+ 0
- 0
var/log/.gitkeep Voir le fichier


Chargement…
Annuler
Enregistrer