3

I'm now still in development my own CMS. can somebody inform me the list of function in PHP to check the performance of my script,

example:

  1. check how much resource needed to run my script
  2. check MySQL query time
  3. check script execution time and etc.

or maybe even if possible the javascript to check my JS script performance too

thanks

GusDeCooL
  • 5,639
  • 17
  • 68
  • 102

4 Answers4

5

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.

Community
  • 1
  • 1
Halil Özgür
  • 15,731
  • 6
  • 49
  • 56
  • i already install Xdebug for pro-filler, but for me this still not comfortable. i more interest how to see the speed in direct in my browser, such us 'echo $function_to_see_performance' :) – GusDeCooL Nov 13 '10 at 15:41
  • If you need to see the total time, just add `$start = microtime();` to the very beginning of your scripts, and do an `echo 'Page generation time: '.(microtime() - $start);` at the very end. But this only provides the total time, which is rarely useful for optimization. – Halil Özgür Nov 13 '10 at 15:50
0

memory_get_usage(true) - one of that you may be interested in

David
  • 10,458
  • 1
  • 28
  • 40
LINKeRxUA
  • 559
  • 6
  • 26
0

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

Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144
0

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

sclarson
  • 4,362
  • 3
  • 32
  • 44