I'm now still in development my own CMS. can somebody inform me the list of function in PHP开发者_JAVA百科 to check the performance of my script,
example:
- check how much resource needed to run my script
- check MySQL query time
- check script execution time and etc.
or maybe even if possible the javascript to check my JS script performance too
thanks
You need profilers. There exists different profilers for PHP, Javascript and MySQL.
For PHP, a Google query and SO posts like Simplest way to profile a PHP script can help.
For Javascript, you can use Firebug.
For MySQL, follow general MySQL performance tips like mentioned in "Top performance tips for MySQL" and check your slow query log.
One way is to log the elapsed time using microtime:
http://us2.php.net/microtime
Log this before and after your script(s) and subtract them to find the execution time.
There is also a pre-built class that may be of better use:
http://codeaid.net/php/calculate-script-execution-time-%28php-class%29
Writing your own CMS can be a great learning experience but if you haven't done so already I'd' highly suggest evaluating what is out there. There is a lot of coding to catch up to drupal, wordpress, and joomla vs extending them.
You can time things using functions like http://php.net/manual/en/function.microtime.php
Alternatively you can monitor your mysql performance from mysql itself with MySQL Query Profiler: http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html
memory_get_usage(true)
- one of that you may be interested in
精彩评论