how to find the time taken to execute php script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sivaji

    how to find the time taken to execute php script

    Is there any function or variable that return the time taken to
    execute a part or full php script .
  • Guillaume

    #2
    Re: how to find the time taken to execute php script

    sivaji a écrit :
    Is there any function or variable that return the time taken to
    execute a part or full php script .
    No, but you can use microtime() to generate a timer at the start and at
    the end of your page, and minus them.

    Regards,
    --
    Guillaume

    Comment

    • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

      #3
      Re: how to find the time taken to execute php script

      sivaji escribió:
      Is there any function or variable that return the time taken to
      execute a part or full php script .
      Apart from microtime(), if your PHP version is great or equal than 5.1.0
      you should have a variable called $_SERVER['REQUEST_TIME'] that contains
      a Unix timestamp of when the request was received. That allows you to
      count time until the first line of the script is actually executed.


      --
      -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
      -- Mi sitio sobre programación web: http://bits.demogracia.com
      -- Mi web de humor al baño María: http://www.demogracia.com
      --

      Comment

      • sivaji

        #4
        Re: how to find the time taken to execute php script

        On May 14, 7:16 pm, "Álvaro G. Vicario"
        <alvaroNOSPAMTH A...@demogracia .comwrote:
        sivaji escribió:
        >
        Is there any function or variable that return the time taken to
        execute a part or full php script .
        >
        Apart from microtime(), if your PHP version is great or equal than 5.1.0
        you should have a variable called $_SERVER['REQUEST_TIME'] that contains
        a Unix timestamp of when the request was received. That allows you to
        count time until the first line of the script is actually executed.
        ya i got the actual code i need ,

        <?php
        $time_start = microtime(true) ;

        // Sleep for a while
        usleep(100000);

        $time_end = microtime(true) ;
        $time = $time_end - $time_start;

        echo "Did nothing in $time seconds\n";
        ?>

        thanks to all

        Comment

        Working...