Re: [PHP3] time a php page From: Michael Stearne (mstearne <email protected>)
Date: 03/01/00

That's basically what I do. There is no script_run_time function built in (so
far).

Michael

GPB wrote:

> What I would like to know is if there is a simple way to time how long php
> takes to generate a page.
>
> There is the set_time_limit() function as well as max_execution_time , so
> php obviously has some internal mechanism for timing a script.
>
> Is it possible to access the value of the time counter in a script?
>
> Here is what I am currently doing (but I'd certainly like something more
> efficient/elegant):
>
> // functions
> function getmicrotime() {
> $mtime = microtime();
> $mtime = explode(" ",$mtime);
> $mtime = $mtime[1] + $mtime[0];
> return $mtime;
> }
>
> function buildfoot($begun = "1") {
> $endtime = getmicrotime();
> $pagetime = ceil($endtime - $begun);
> $foot = "<p>$pagetime second(s)
> </body>
> </html>";
> return $foot;
> }
>
> // at the start of the script
> $begintime = getmicrotime();
>
> // a whole bunch of stuff here that takes a long time and prints out a lot
> of html
>
> // and finally, print the end of the page
> print buildfoot($begintime);
>
> --
> PHP 3 Mailing List <http://www.php.net/>
> To unsubscribe, send an empty message to php3-unsubscribe <email protected>
> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
> To contact the list administrators, e-mail: php-list-admin <email protected>

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>