Finding slower part of the code in PHP

Sometimes we analyze that our PHP script is running very slow, we, just think that may be reason is our loop and the fetching data through the sql query etc . But we do not know that where is actual problem? We actually don't know in which function or method execution is very slow? I this post I will let you know how to find out the slower part of your PHP script, it can be measured by the little code which check the speed of your PHP script,

Write this function on top of your PHP script or in any other file and include that in the page where you want to measure the speed issue,

After that call this function after execution of your function and methods, this will return the execution time. and then you check performance of your code.

speedcheck(); /*Initialize the function */
/*-----Your Code---*/
echo speedcheck();
/* Some more code */
echo speedcheck();

/* Yet more code */

echo speedcheck();


Thats it, now you will compare the performance time and analyse your code accordingly.

Thanks & Enjoy the PHP Coding.