|
Posted by Erwin Moller on 11/29/07 09:03
Hermann wrote:
> To explain what I need to do I'm gonna cite an excerpt of
> set_time_limit's php documentation:
>
> "The set_time_limit() function and the configuration directive
> max_execution_time only affect the execution time of the script
> itself. Any time spent on activity that happens outside the execution
> of the script such as system calls using system(), stream operations,
> database queries, etc. is not included when determining the maximum
> time that the script has been running."
>
> So, subtracting the script's start-time from the script's end-time
> wont give you the actual execution time but the total time spent on
> doing everything the script did.
>
> I need a way to know the real execution time so I can know how much
> time is left for the script to execute. And depending on that, to make
> decisions about whether to continue with the current task the script
> is doing or to end the script if there is not enough time left.
>
>
> Any idea would be apreciated.
> Thanks.
Hi,
Simply use multiple checkpoints where you store microtime() in your
script. Place them at strategical places.
eg:
$myTimer = array();
// at start
$myTimer["start"] = microtime();
// before query1
$myTimer["beforeQ1"] = microtime();
// after query 1
$myTimer["afterQ1"] = microtime();
etc. etc.
And at the end inspect $myTimer.
You can decide during the script if too much time is spend anywhere and
take appropriate action.
Hope this help.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|