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édenteDernière révisionLes deux révisions suivantes | ||
informatique:php:performance [10/12/2009 14:59] – cyrille | informatique:php:performance [23/07/2016 13:47] – [Profiling] 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 | ||
==== Caching ==== | ==== Caching ==== | ||
Ligne 19: | Ligne 32: | ||
==== 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 41: | Ligne 64: | ||
- | * APC (open source) : http:// | + | |
- | * eAccelerator (open-source) : http:// | + | * XCache |
- | * Zend Platform (payant) : http:// | + | |
- | * FPM SAPI: http:// | + | * Zend Platform (payant) : http:// |
+ | * FPM SAPI: http:// | ||
==== Use big realpath cache ==== | ==== Use big realpath cache ==== |
informatique/php/performance.txt · Dernière modification : 23/07/2016 13:49 de cyrille