informatique:php:performance
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
informatique:php:performance [09/12/2009 11:35] – cyrille | informatique:php:performance [23/07/2016 13:49] (Version actuelle) – [Profiling] nalyser les données du profiler de XDebug avec webgrind cyrille | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== PHP Performance ====== | ====== PHP Performance ====== | ||
+ | |||
+ | Voir aussi: | ||
+ | * [[/ | ||
===== Articles ===== | ===== Articles ===== | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | * [[http:// | ||
===== At developpment time ===== | ===== At developpment time ===== | ||
Ligne 10: | Ligne 16: | ||
Profile you code before you start optimizing it! Otherwise it would be like travelling around a foreign city with signs written in an unreadable language witout any map or GPS. You’ll probably get somewhere, but you wouldn’t have any idea where you are, where you should go and how far are you from the place you need to be. Profiling would allow you to know which parts of code are worth investing into and which aren’t. You can use [[http:// | Profile you code before you start optimizing it! Otherwise it would be like travelling around a foreign city with signs written in an unreadable language witout any map or GPS. You’ll probably get somewhere, but you wouldn’t have any idea where you are, where you should go and how far are you from the place you need to be. Profiling would allow you to know which parts of code are worth investing into and which aren’t. You can use [[http:// | ||
+ | |||
+ | * https:// | ||
+ | * xdebug.profiler_enable_trigger = 1 with XDEBUG_PROFILE set in GET/POST or COOKIE | ||
+ | * ou xdebug.profiler_enable = 1 | ||
+ | * [[http:// | ||
+ | * xdebug.auto_trace = On | ||
+ | * xdebug.show_mem_delta = On | ||
+ | |||
+ | Analyser les données du profiler de XDebug avec [[https:// | ||
==== Caching ==== | ==== Caching ==== | ||
Ligne 19: | Ligne 34: | ||
==== Optimize your data ==== | ==== Optimize your data ==== | ||
- | Usually the most expensive places of the PHP application are where it accesses external data – namely, database or filesystem | + | Usually the most expensive places of the PHP application are where it accesses external data – namely, database or file system |
==== Avoid extra notices/ | ==== Avoid extra notices/ | ||
Even suppressed errors have cost in PHP, so try and write your code so it would not produce notices, strict notices, warnings, etc. You may want to enable logging of all errors to examine that. Never enable displaying errors in production though – it will only lead to a major public embarrassment. | Even suppressed errors have cost in PHP, so try and write your code so it would not produce notices, strict notices, warnings, etc. You may want to enable logging of all errors to examine that. Never enable displaying errors in production though – it will only lead to a major public embarrassment. | ||
+ | |||
+ | ==== Eviter PREG ==== | ||
+ | |||
+ | Utiliser preg_* seulement quand on ne peut pas faire autrement. | ||
+ | |||
+ | stripos(' | ||
+ | |||
+ | ctype_alnum() est 5 fois plus rapide que preg_match('/ | ||
+ | |||
+ | Casting " | ||
===== At build time ===== | ===== At build time ===== | ||
Ligne 40: | Ligne 65: | ||
A bytecode cache like APC will cache the bytecode that is generated by php prior to executing it. That means that the parsing of a file and the creation of the bytecode happens only once and not on every request. This is especially useful when using large libraries and/or frameworks. Together with file bundling for production this should give you a significant performance improvement. To get the most out of a bytecode cache you should contact the manual pages since most of these caches have a lot of configuration options which you can tweak to optimize the cache to your needs. | A bytecode cache like APC will cache the bytecode that is generated by php prior to executing it. That means that the parsing of a file and the creation of the bytecode happens only once and not on every request. This is especially useful when using large libraries and/or frameworks. Together with file bundling for production this should give you a significant performance improvement. To get the most out of a bytecode cache you should contact the manual pages since most of these caches have a lot of configuration options which you can tweak to optimize the cache to your needs. | ||
- | FPM SAPI: http:// | + | |
+ | * APC (open source) : http:// | ||
+ | * XCache | ||
+ | * eAccelerator (open-source) : http:// | ||
+ | * Zend Platform (payant) : http:// | ||
+ | * FPM SAPI: http:// | ||
==== Use big realpath cache ==== | ==== Use big realpath cache ==== |
informatique/php/performance.1260354907.txt.gz · Dernière modification : 19/05/2012 00:15 (modification externe)