Просмотр исходного кода

Create Hello world benchmark

tags/4.1.9.1
Steevan BARBOYON 7 лет назад
Родитель
Сommit
2f88bf5cc0

+ 0
- 10
.env.dist Просмотреть файл

@@ -1,10 +0,0 @@
1
-# This file is a "template" of which env vars need to be defined for your application
2
-# Copy this file to .env file for development, create environment variables when deploying to production
3
-# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4
-
5
-###> symfony/framework-bundle ###
6
-APP_ENV=dev
7
-APP_SECRET=d541f5e8a0e110cb270cedcb8fc2c769
8
-#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9
-#TRUSTED_HOSTS=localhost,example.com
10
-###< symfony/framework-bundle ###

+ 1
- 0
.gitignore Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 .idea/
2
+composer.lock
2 3
 
3 4
 ###> symfony/framework-bundle ###
4 5
 /.env

+ 27
- 0
README.md Просмотреть файл

@@ -0,0 +1,27 @@
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
- 24
bin/console Просмотреть файл

@@ -11,29 +11,6 @@ set_time_limit(0);
11 11
 
12 12
 require __DIR__.'/../vendor/autoload.php';
13 13
 
14
-if (!class_exists(Application::class)) {
15
-    throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
16
-}
17
-
18
-if (!isset($_SERVER['APP_ENV'])) {
19
-    if (!class_exists(Dotenv::class)) {
20
-        throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
21
-    }
22
-    (new Dotenv())->load(__DIR__.'/../.env');
23
-}
24
-
25
-$input = new ArgvInput();
26
-$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
27
-$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
28
-
29
-if ($debug) {
30
-    umask(0000);
31
-
32
-    if (class_exists(Debug::class)) {
33
-        Debug::enable();
34
-    }
35
-}
36
-
37
-$kernel = new Kernel($env, $debug);
14
+$kernel = new Kernel('prod', false);
38 15
 $application = new Application($kernel);
39 16
 $application->run($input);

+ 3
- 11
composer.json Просмотреть файл

@@ -9,12 +9,10 @@
9 9
         "symfony/flex": "^1.0",
10 10
         "symfony/framework-bundle": "4.1.0-BETA2",
11 11
         "symfony/lts": "^4@dev",
12
-        "symfony/yaml": "4.1.0-BETA2"
12
+        "symfony/yaml": "4.1.0-BETA2",
13
+        "phpbenchmarks/symfony-common": "4.1.0"
13 14
     },
14 15
     "minimum-stability": "beta",
15
-    "require-dev": {
16
-        "symfony/dotenv": "^4.0"
17
-    },
18 16
     "config": {
19 17
         "preferred-install": {
20 18
             "*": "dist"
@@ -26,11 +24,6 @@
26 24
             "App\\": "src/"
27 25
         }
28 26
     },
29
-    "autoload-dev": {
30
-        "psr-4": {
31
-            "App\\Tests\\": "tests/"
32
-        }
33
-    },
34 27
     "replace": {
35 28
         "symfony/polyfill-iconv": "*",
36 29
         "symfony/polyfill-php71": "*",
@@ -39,8 +32,7 @@
39 32
     },
40 33
     "scripts": {
41 34
         "auto-scripts": {
42
-            "cache:clear": "symfony-cmd",
43
-            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
35
+            "cache:clear": "symfony-cmd"
44 36
         },
45 37
         "post-install-cmd": [
46 38
             "@auto-scripts"

composer.lock → composer.lock.php7.1 Просмотреть файл

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

+ 1380
- 0
composer.lock.php7.2
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 0
config/bundles.php Просмотреть файл

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

+ 0
- 3
config/packages/dev/routing.yaml Просмотреть файл

@@ -1,3 +0,0 @@
1
-framework:
2
-    router:
3
-        strict_requirements: true

+ 0
- 26
config/packages/framework.yaml Просмотреть файл

@@ -1,30 +1,4 @@
1 1
 framework:
2 2
     secret: '%env(APP_SECRET)%'
3
-    #default_locale: en
4
-    #csrf_protection: true
5
-    #http_method_override: true
6
-
7
-    # Enables session support. Note that the session will ONLY be started if you read or write from it.
8
-    # Remove or comment this section to explicitly disable session support.
9
-    session:
10
-        handler_id: ~
11
-
12
-    #esi: true
13
-    #fragments: true
14 3
     php_errors:
15 4
         log: true
16
-
17
-    cache:
18
-        # Put the unique name of your app here: the prefix seed
19
-        # is used to compute stable namespaces for cache keys.
20
-        #prefix_seed: your_vendor_name/app_name
21
-
22
-        # The app cache caches to the filesystem by default.
23
-        # Other options include:
24
-
25
-        # Redis
26
-        #app: cache.adapter.redis
27
-        #default_redis_provider: redis://localhost
28
-
29
-        # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
30
-        #app: cache.adapter.apcu

+ 0
- 4
config/packages/test/framework.yaml Просмотреть файл

@@ -1,4 +0,0 @@
1
-framework:
2
-    test: true
3
-    session:
4
-        storage_id: session.storage.mock_file

+ 2
- 3
config/routes.yaml Просмотреть файл

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

+ 1
- 27
config/services.yaml Просмотреть файл

@@ -1,27 +1 @@
1
-# Put parameters here that don't need to change on each machine where the app is deployed
2
-# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
3
-parameters:
4
-
5
-services:
6
-    # default configuration for services in *this* file
7
-    _defaults:
8
-        autowire: true      # Automatically injects dependencies in your services.
9
-        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
10
-        public: false       # Allows optimizing the container by removing unused services; this also means
11
-                            # fetching services directly from the container via $container->get() won't work.
12
-                            # The best practice is to be explicit about your dependencies anyway.
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/{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
1
+# useless for us, but needed by Symfony Flex

+ 28
- 0
init_benchmark.sh Просмотреть файл

@@ -0,0 +1,28 @@
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
+    export APP_ENV='prod'
19
+
20
+    clearCacheAndLogs
21
+
22
+    composer install --no-dev --classmap-authoritative
23
+    [ "$?" != "0" ] && exit 1
24
+
25
+    clearCacheAndLogs
26
+
27
+    return 0
28
+}

+ 3
- 26
public/index.php Просмотреть файл

@@ -7,33 +7,10 @@ use Symfony\Component\HttpFoundation\Request;
7 7
 
8 8
 require __DIR__.'/../vendor/autoload.php';
9 9
 
10
-// The check is to ensure we don't use .env in production
11
-if (!isset($_SERVER['APP_ENV'])) {
12
-    if (!class_exists(Dotenv::class)) {
13
-        throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
14
-    }
15
-    (new Dotenv())->load(__DIR__.'/../.env');
16
-}
17
-
18
-$env = $_SERVER['APP_ENV'] ?? 'dev';
19
-$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
20
-
21
-if ($debug) {
22
-    umask(0000);
23
-
24
-    Debug::enable();
25
-}
26
-
27
-if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
28
-    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
29
-}
30
-
31
-if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
32
-    Request::setTrustedHosts(explode(',', $trustedHosts));
33
-}
34
-
35
-$kernel = new Kernel($env, $debug);
10
+$kernel = new Kernel('prod', false);
36 11
 $request = Request::createFromGlobals();
37 12
 $response = $kernel->handle($request);
38 13
 $response->send();
39 14
 $kernel->terminate($request, $response);
15
+
16
+// require phpbenchmarks stats.php here when needed

+ 0
- 0
src/Controller/.gitignore Просмотреть файл


+ 12
- 15
src/Kernel.php Просмотреть файл

@@ -17,17 +17,17 @@ class Kernel extends BaseKernel
17 17
 
18 18
     public function getCacheDir()
19 19
     {
20
-        return $this->getProjectDir().'/var/cache/'.$this->environment;
20
+        return $this->getProjectDir() . '/var/cache/' . $this->environment;
21 21
     }
22 22
 
23 23
     public function getLogDir()
24 24
     {
25
-        return $this->getProjectDir().'/var/log';
25
+        return $this->getProjectDir() . '/var/log';
26 26
     }
27 27
 
28 28
     public function registerBundles()
29 29
     {
30
-        $contents = require $this->getProjectDir().'/config/bundles.php';
30
+        $contents = require $this->getProjectDir() . '/config/bundles.php';
31 31
         foreach ($contents as $class => $envs) {
32 32
             if (isset($envs['all']) || isset($envs[$this->environment])) {
33 33
                 yield new $class();
@@ -37,25 +37,22 @@ class Kernel extends BaseKernel
37 37
 
38 38
     protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
39 39
     {
40
-        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
41
-        // Feel free to remove the "container.autowiring.strict_mode" parameter
42
-        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
43
-        $container->setParameter('container.autowiring.strict_mode', true);
40
+        $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
44 41
         $container->setParameter('container.dumper.inline_class_loader', true);
45
-        $confDir = $this->getProjectDir().'/config';
42
+        $confDir = $this->getProjectDir() . '/config';
46 43
 
47
-        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
48
-        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
49
-        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
50
-        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
44
+        $loader->load($confDir . '/{packages}/*' . static::CONFIG_EXTS, 'glob');
45
+        $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . static::CONFIG_EXTS, 'glob');
46
+        $loader->load($confDir . '/{services}' . static::CONFIG_EXTS, 'glob');
47
+        $loader->load($confDir . '/{services}_' . $this->environment . static::CONFIG_EXTS, 'glob');
51 48
     }
52 49
 
53 50
     protected function configureRoutes(RouteCollectionBuilder $routes)
54 51
     {
55 52
         $confDir = $this->getProjectDir().'/config';
56 53
 
57
-        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
58
-        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
59
-        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
54
+        $routes->import($confDir . '/{routes}/*' . static::CONFIG_EXTS, '/', 'glob');
55
+        $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . static::CONFIG_EXTS, '/', 'glob');
56
+        $routes->import($confDir . '/{routes}' . static::CONFIG_EXTS, '/', 'glob');
60 57
     }
61 58
 }

+ 3
- 0
symfony.lock Просмотреть файл

@@ -1,4 +1,7 @@
1 1
 {
2
+    "phpbenchmarks/symfony-common": {
3
+        "version": "4.1.0"
4
+    },
2 5
     "psr/cache": {
3 6
         "version": "1.0.1"
4 7
     },

Загрузка…
Отмена
Сохранить