Search code examples
phpexecute

Duration time to execute in PHP


I need to program something in PHP but i have to know execution time between my line 5 and my line 14.

The problem is that i don't find anything to do what i want (calculate execution time between that lines).

How can i synchronize it with another action ?

Thanks.


Solution

  • I made a post about it on my website after some search.

    You can add before :

    $mtime = microtime();
    $mtime = explode(" ",$mtime);
    $mtime = $mtime[1] + $mtime[0];
    $starttime = $mtime;
    

    And after your code :

    $mtime = microtime();
    $mtime = explode(" ",$mtime);
    $mtime = $mtime[1] + $mtime[0];
    $endtime = $mtime;
    $totaltime = ($endtime - $starttime);
    echo "Executed in ".$totaltime." seconds";
    

    What do you mean by synchonizing it ? Launching something else ? Be more precise for that part.