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

1
  • 1
    microtime() is your friend... Commented Nov 13, 2010 at 15:15

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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' :)
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.
0

One way is to log the elapsed time using microtime:

https://www.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

1 Comment

Thanks for pre-built class :)
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

1 Comment

thank you very much for the link, i use modx to catch up how CMS work :)
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.