Please let me know about that How can I measure the speed code written in Php.?
Depends what you are trying to do.
Is this a Moodle specific question? If so, Moodle has built-in support for profiling with xdebug or xhprof ( https://docs.moodle.org/dev/Profiling_PHP ).
If its a more general question about PHP, then I suggest searching for 'php profiling' in your favourite search engine and then reading through some of the results found.