Profiling, a very interesting topic. Some time ago, I tried to find the peak memory usage because my program does a lot of memory free actions. Here is how I did it. One is PHP5 only, the other is *nix only. So if you have PHP4 and using Windows.. Shame on you :)
The PHP5 only option.
<?php
Echo memory_get_peak_usage();
?>
The *nix only option.
<?php
function get_max_mem($dump){
static $mem;
$a = memory_get_usage();
if($a>$mem){
$mem = $a;
}
if($dump){
return $mem;
}
}
register_tick_function('get_max_mem');
get_max_mem();
declare(ticks=1);
//now put everything above on top of the script
//everything below on end of the script.
echo get_max_mem(TRUE);
?>