Re: [PHP] Speed tests? RAM usage displays?
At 6/21/2002, you wrote: >PS> What about execution time in ms (with breakpoints)? >PS> And is there way to measure MySQL query speed in ms? > >u can use microtime function > > function getMicrotime() > { > list($usec, $sec) = explode(" ",microtime()); > return ((float)$usec + (float)$sec); > } > >in your head of your script than call: > >$start = getMicrotime(); > >and then in the end of script > >$stop = getMicrotime(); >$diff = $stop - $start; >echo "Execution time was: ".$diff; Thanks! That was really useful. I placed it around the biggest/most complex MySQL query on the code and found out that the biggest slow down there was due ORDER BY command (and not LIKE I thought was). So, I removed the ORDER BY and did array sorting using PHP (PHP did it in less than a millisecond) and got this query speed down from .25s to .07s Optimising can be so much fun! ;) Pekka http://photography-on-the.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Speed tests? RAM usage displays?
Hi! Thursday, June 20, 2002, 10:56:40 PM, you wrote: PS> Is there any way to determine script's memory usage? When you configure and compile you have some option --with-memory-limit something like that and then add \"%{mod_php_memory_usage}n\" in you http.conf of Apache where you define how log files look like. PS> What about execution time in ms (with breakpoints)? PS> And is there way to measure MySQL query speed in ms? u can use microtime function function getMicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } in your head of your script than call: $start = getMicrotime(); and then in the end of script $stop = getMicrotime(); $diff = $stop - $start; echo "Execution time was: ".$diff; You can also use Benchmark module from PEAR there is also support for markers. -- lp, Urosmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Speed tests? RAM usage displays?
> Is there any way to determine script's memory usage? Depends on your web server. There is a way in apache. Rasmus answered this same question for me a couple weeks ago, look through the archives. I saw an option in IIS to put memory usage into the logs, that may work, too. > What about execution time in ms (with breakpoints)? Plenty of classes around that'll do basic timing, but not sure on the breakpoint. shouldn't be that hard to implement, though. PEAR has a class to do it, I think, or search phpclasses.org > And is there way to measure MySQL query speed in ms? Not really. I really wish there was a function to return query time, but there isn't. Best you can do is take a timestamp before you issue the query and one afterwards. That's not going to be the actual query time, but it'll give you an idea. Best way to implement that is to make a wrapper for mysql_query() ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php