Benchmark extension

Hi,

Is there a standard way to benchmark the code? Tired of




$start = time();

// do something

print time()-$start;



Ideas?

Is this what you want?

http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#performance-profiling

Nope. It just outputs two timestamps, at start and end points. I need something robust yet simple to use and, ideally, served as app logic logging :)

Something like in the following pseudo code:




start_benchmark("Big Chank");

benchmark("op #1")

// lengthy op


loop

  benchmark("op in a loop")

  // heavy stuff

end_loop


end_benchmark()



and the expected output should be:




Big Chank started at 12:34

2.318s op #1

100 times "op in a loop": 0.15s average

Big Chank finished in 1m 54s



Hopefully, that’s more clear of what I want. Am I asking too much?

:lol:

Just made an extension - Benchmark. It does exactly that I was asking for, and a bit more :slight_smile:

It even supports continuous logging in forked kids. I’m working on the extensive description, but since the source code is well commented and a unit test is included, it should be very easy to figure out how to use it.