Can anyone tell me a simple way to time a bunch of functions so's I can see where I am bottlenecking my code?
Cheers,
HKSure...
Read the user comments here:
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.microtime.php">http://www.php.net/manual/en/function.microtime.php</a><!-- m -->
That'll show you how to make timing functions, using microtime(). Then I guess you just add some kind of start and stop before and after each function call, and print the results...
There are also other ways.. Some IDE's include features that will time your scripts.. A 'profiler'... Zend Studio and PHPEd have that for example, but of course, they come with a pricetag.<!-- m --><a class="postlink" href="http://www.snippetlibrary.com/code.php?id=6&kid=54&catname=Statisticsgreat">http://www.snippetlibrary.com/code.php? ... sticsgreat</a><!-- m --> guys - thanks.
I'm using the information from PHP.net that Rydberg linked to.
Problem is, I think the long times are coming from my database queries and data manipulation.
(trying to display data from a logfile of temperatures and such, stretching back over years!)
I could get millions of datapoints.
I'm testing with about 4,000 datapoints, taken only over couple of hours!
Takes about 20 secondsWell that'll make the processor sweat, for sure ...
set_time_limit(0), or such, might come in handy...that is what my script does. it uses the samething Rydberg linked to.
if you didn't calculate the time correct then the time will be wrong
Cheers,
HKSure...
Read the user comments here:
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.microtime.php">http://www.php.net/manual/en/function.microtime.php</a><!-- m -->
That'll show you how to make timing functions, using microtime(). Then I guess you just add some kind of start and stop before and after each function call, and print the results...
There are also other ways.. Some IDE's include features that will time your scripts.. A 'profiler'... Zend Studio and PHPEd have that for example, but of course, they come with a pricetag.<!-- m --><a class="postlink" href="http://www.snippetlibrary.com/code.php?id=6&kid=54&catname=Statisticsgreat">http://www.snippetlibrary.com/code.php? ... sticsgreat</a><!-- m --> guys - thanks.
I'm using the information from PHP.net that Rydberg linked to.
Problem is, I think the long times are coming from my database queries and data manipulation.
(trying to display data from a logfile of temperatures and such, stretching back over years!)
I could get millions of datapoints.
I'm testing with about 4,000 datapoints, taken only over couple of hours!
Takes about 20 secondsWell that'll make the processor sweat, for sure ...
set_time_limit(0), or such, might come in handy...that is what my script does. it uses the samething Rydberg linked to.
if you didn't calculate the time correct then the time will be wrong