1. very nice. I took a slightly different approach, though. The timer we use allows you to “mark” points in the code and then call an “elapsed” method to see the difference between any two of the points.

    so I would do
    $bm = new Benchmark();
    //code here
    echo $bm->elapsed(‘start’, ‘end’);

    I could probably add a contsruct method to auto set the first mark, and after looking at your code I might just do that. I like this method because It allows me to use more semantic names to mark certain places in the code (or even add time to a certain mark in a loop or DB query time, etc..) and easily recall why I was doing that, later.

    August 17, 2009 at 7:24 am |
  2. Yeah, I agree. the prefix idea is pretty interesting. But then I think we’re starting to over-complicate a timer :)

    If I added a construct for the “start” marker and then a new “end” method that would basically take the difference from start to end, that might be handy.

    You could easily do:
    $bm = new Benchmark();
    //code here
    echo $bm->end();

    that would allow you to do the simple start/end timer but also give you the capability to mark other places. And you could just call new instances of the class to get other start points.

    $bm = new Benchmark();
    //code here
    echo $bm->end();

    $bm_alt = new Benchmark();
    //other code here
    echo $bm_alt->end();

    August 17, 2009 at 7:49 am |
  3. Good ideas, for sure.

    BTW, what were your results with the Packer port?

    August 17, 2009 at 8:03 am |

Leave a Reply

You must be logged in to post a comment.