环境
-
centos7 + docker(alpine3.7)
- 1核
- 内存2G
- php7.1.17
- 开启opcache
- 性能监控tideways_xhprof
-
composer 使用生产环境命令进行安装
composer install --no-dev --optimize-autoloader --prefer-dist
统一执行 vension 打印
框架 | 执行时间 | 内存 |
---|---|---|
lumen | 8ms | 0.4MB |
lumen + Facades | 8.5ms | 0.5MB |
lumen + Facades + Eloquent | 13ms~14ms | 0.8MB |
laravel | 50ms~60ms | 1.6MB |
最主要差异:33.667ms
- 加载所有config文件:6.711ms
- Provider register: 5.756ms
- Provider boot: 8.048ms
- Route Middleware: 9.084ms
- terminateMiddleware: 4.068ms
lumen + Facades + Eloquent 整理时间线
-
整体
- 执行时间: 13.284ms
- cpu时间: 13.1ms
-
public/index.php
-
bootstrap/app.php
- vendor/autoload.php: 0.617ms
- Dotenv load: 1.882ms
改为php加载
- Application::__construct: 0.674ms
- withFacades: 0.455ms
-
withEloquent: 5.144ms
如何动态加载?
-
loadComponent database: 4.931ms
- configure: 0.5ms ==可优化==
-
DatabaseServiceProvider
- register: 0.684ms
- boot: 0.981ms
-
PaginationServiceProvider
- register: 0.167ms
- boot: 2.115ms
可优化
-
- Router::group: 0.215ms
-
Application::run: 3.758ms
-
dispatch: 3.479ms
-
parseIncomingRequest: 2.643ms
-
Request::capture: 2.007ms
-
Request::createFromGlobals: 0.984ms
-
Request::createRequestFromFactory: 0.947ms
- Request::initialize: 0.982ms
-
-
Request::createFromBase: 1.005ms
- Request::duplicate: 0.789ms
为什么需要复制一份?
- Request::duplicate: 0.789ms
-
-
- sendThroughPipeline: 0.826ms
-
- Response::send: 0.263ms
-
-
laravel 整理时间线
-
整体
- 执行时间:54.3ms
- CPU时间:53.2ms
-
public/index.php
- vendor/autoload.php: 0.926ms
-
bootstrap/app.php
-
Application::__construct: 1.471ms
- registerBaseServiceProviders: 0.708ms
- make Kernel: 1.3ms
- Request::capture: 1.841ms
-
kernel::handle: 43.308ms
-
Kernel::sendRequestThroughRouter: 43.117ms
-
bootstrap: 28.188ms
-
Application::bootstrapWith: 28.175ms
-
LoadEnvironmentVariables::bootstrap: 4.372ms
- Dotenv::load: 4.212ms
- LoadConfiguration::bootstrap: 6.711ms
加载所有config文件,差异
- RegisterFacades::bootstrap: 0.587ms
-
RegisterProviders::bootstrap: 5.657ms
Provider register 差异
- Collection::partition: 0.8ms
-
ProviderRepository::load: 4.250ms
- IlluminateAuthAuthServiceProvider
- IlluminateCookieCookieServiceProvider
- IlluminateDatabaseDatabaseServiceProvider
- IlluminateEncryptionEncryptionServiceProvider
- IlluminateFilesystemFilesystemServiceProvider
- IlluminateFoundationProvidersFoundationServiceProvider
- IlluminateNotificationsNotificationServiceProvider
- IlluminatePaginationPaginationServiceProvider
- IlluminateSessionSessionServiceProvider
- IlluminateViewViewServiceProvider
- FideloperProxyTrustedProxyServiceProvider
- AppProvidersAppServiceProvider
- AppProvidersAuthServiceProvider
- AppProvidersEventServiceProvider
- AppProvidersRouteServiceProvider
-
BootProviders::bootstrap: 8.048ms
Provider boot 差异
- array_walk: 7.793ms
-
-
-
Pipeline::then: 14.690ms
-
Router::dispatch: 12.202ms
- findRoute: 1.754ms
-
runRoute: 10.434ms
-
runRouteWithinStack: 9.084ms
Middleware 差异
- Pipeline::then: 8.586ms
-
prepareResponse: 2.220ms
- prepare: 1.6ms
-
-
-
-
- Response::send: 0.591ms
-
Kernel::terminate: 4.068ms
-
Kernel::terminateMiddleware: 4.056ms
- StartSession::terminate: 0.915ms
-
-
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。