You are here: Re: How to now the script execution time? « PHP Programming Language « IT news, forums, messages
Re: How to now the script execution time?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация