Benchmark tool

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    Benchmark tool

    Anybody recommend a reliable benchmark tool for PHP.
    I have been using Timer.php which is an old PEAR class, but I am discovering it's accuracy is very poor.

    A simple class that tells the truth is all I need
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    What do you need to benchmark? How long a specific task takes to execute? Resources used? When I need to know how long a task takes I simply create a time_start and time_end variable using this:

    array_sum(explo de(' ', microtime()));

    Then subtract the start from the end and round the result to whatever depth you want. I usually show two decimal places. Full code:

    Code:
    $t_start = array_sum(explode(' ', microtime()));
    
    // Some code
    
    $exectime = round(array_sum(explode(' ', microtime())) - $t_start, 4);
    echo "Execution time: " . $exectime;
    Will give you the time it took to process "some code" to a precision of 4 decimal places. Works well for me.

    Hopefully this is somewhat close to what you were looking for.

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      It would be hard work to copy a paste 2-3 lines of code all over the place in some of the huge projects I use.
      At the moment I use one line as a marker
      $t->setMarker('Fla g Name'), and the results are output tidily at the end of execution in a table, rather than buried amongst all the other debugging output.

      But Timer.php tells lies. Especially early in the execution where the time can be applied to the wrong marker.

      I am just wondering if any has used anything better.
      If not I will have to write my own.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I use XDebug in combination with a cache grinder.
        Last edited by Dormilich; Aug 20 '10, 06:36 AM.

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          I use XDebug in combination with a cache grinder.
          That sounds complicated although I have no idea what they are :)

          The performance I am measuring are purely database and function / class calls directly on a server.
          There is no parsing of web pages or server connection issues (maybe a little, but only on intranet).
          For example a script this morning took ~2 minutes in total to run.
          The longest section was 48 seconds for a MsSQL query.

          I need to identify this type of thing.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            XDebug is a PHP extension which provides debugging and profiling capabilities.

            a cache grinder is a tool to make profiling information visible (cf. KCacheGrind, webcachegrind and the additional info at XDebug)

            Comment

            Working...