...

View Full Version : Tell how long a script is running for?



x_goose_x
04-19-2003, 06:10 PM
Is there any way to tell how long a script has been running for?

fshiu
04-21-2003, 08:39 AM
Hey,

I'm not sure what you mean. Do you mean the time required for a page to load? If so...

At the top of the page:



$thing = microtime();


at the bottom of the page:



print "This script took " . microtime()-$thing . " seconds to load.";

missing-score
04-21-2003, 09:20 AM
That would be the best way...

If you wanted to calculate the time taken to do a query on a database or something like that, you would just put the same around the particular part of the code.

x_goose_x
04-21-2003, 06:58 PM
I wanted a notification after a certain amount of time. Do I have to kepp on checking the time? Or is there a way that doesn't put as much of a load on the server?

missing-score
04-21-2003, 07:01 PM
Seeing as PHP is run on the server, I wouldnt have thought that you could notify half way through, cos It parses everything before the page is returned.

x_goose_x
04-21-2003, 07:38 PM
By default timeout=30s. I want at 29.5 seconds for it to execute a simple function, like:

function pagetimeout() {
exit ("Awww, Dang! We ran outta time!");
}

by notify, i mean tell the remainder of the script that it is about to TO.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum