Benchmarking Zend Framework with a plugin
I have created this plugin to benchmark the performance of my Zend Framework Project
http://pastebin.com/HD9MpRfR
One odd thing that happens is that sometimes the generated values are negative,
Unit: Microseconds
Routing: 0.0013879999999999
Dispatch : -0.477942
Dispatch Loop: -0.470018
To开发者_运维百科tal : -0.430279
Why is this?
Your code is calling microtime()
. I think you need to call it like this: microtime(true)
. According to the PHP documentation:
If used and set to TRUE, microtime() will return a float instead
of a string, as described in the return values section below.
So, you are substracting strings every time. It might lead to strange results.
Also, check the returned *Start
and *End
values, maybe there is some problem in the logic of your plugin (I didn't review it in detail). An alternative technique could be to store these values in Zend_Registry
instead of member variables. Maybe your plugin is being called several times, for startup and shutdown (this would reset the values of the member variables).
Hope that helps,
精彩评论