PHP profiler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mladen Gogala

    #1

    PHP profiler

    I'm looking for a GPL licensed PHP profiler. The best thing around,
    except the commercial goodies from NuSphere, seems to be Carl Taylor's
    toolkit at http://www.adepteo.net/profiler/index.php
    Any experiences? Does anybody here uses profiler to see where the
    application time is spent and which components need fine tuning?

    --
    大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


  • Chung Leong

    #2
    Re: PHP profiler

    Here is a simple profiler I wrote. It uses a tick function to measure
    the time expired between each PHP operation and debug_back_trac e() to
    find out where it occurs. Kinda neat as you don't have to make much
    modification. Just include it at the beginning of the script, then at
    the end, call __profile__('ge t') to obtain the profile data--an
    associative array of percentages keyed by function names.

    profiler.php:
    <?php

    function __profiler__($c md = false) {
    static $log, $last_time, $total;
    list($usec, $sec) = explode(" ", microtime());
    $now = (float) $usec + (float) $sec;
    if($cmd) {
    if($cmd == 'get') {
    unregister_tick _function('__pr ofile__');
    foreach($log as $function => $time) {
    if($function != '__profile__') {
    $by_function[$function] = round($time / $total * 100, 2);
    }
    }
    arsort($by_func tion);
    return $by_function;
    }
    else if($cmd == 'init') {
    $last_time = $now;
    return;
    }
    }
    $delta = $now - $last_time;
    $last_time = $now;
    $trace = debug_backtrace ();
    $caller = $trace[1]['function'];
    @$log[$caller] += $delta;
    $total += $delta;
    }

    __profiler__('i nit');
    register_tick_f unction('__prof iler__');
    declare(ticks=1 );

    ?>

    Comment

    • Chung Leong

      #3
      Re: PHP profiler

      Forgot to mention that as tick functions don't work in a threaded
      environment, you'll need to set up PHP as CGI if you're on Windows.

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: PHP profiler

        Mladen Gogala wrote:[color=blue]
        > I'm looking for a GPL licensed PHP profiler. The best thing around,
        > except the commercial goodies from NuSphere, seems to be Carl Taylor's
        > toolkit at http://www.adepteo.net/profiler/index.php
        > Any experiences? Does anybody here uses profiler to see where the
        > application time is spent and which components need fine tuning?[/color]

        Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
        lacks GUI. We use our own GUI (can't give, sorry).

        --
        <?php echo 'Just another PHP saint'; ?>
        Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

        Comment

        • R. Rajesh Jeba Anbiah

          #5
          Re: PHP profiler

          Chung Leong wrote:[color=blue]
          > Here is a simple profiler I wrote.[/color]
          <snip>

          Hard core programmers like you'll always write codes and would
          restrain to use other tools:( But, I would suggest you to try APD
          <http://in.php.net/apd> and see the difference.

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          • Mladen Gogala

            #6
            Re: PHP profiler

            On Mon, 19 Dec 2005 20:51:10 -0800, R. Rajesh Jeba Anbiah wrote:
            [color=blue]
            > Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
            > lacks GUI. We use our own GUI (can't give, sorry).[/color]

            APD is a debugger, not a profiler. Thanks.

            --
            大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


            Comment

            • Andy Hassall

              #7
              Re: PHP profiler

              On Tue, 20 Dec 2005 15:55:50 GMT, Mladen Gogala <gogala@sbcglob al.net> wrote:
              [color=blue]
              >On Mon, 19 Dec 2005 20:51:10 -0800, R. Rajesh Jeba Anbiah wrote:
              >[color=green]
              >> Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
              >> lacks GUI. We use our own GUI (can't give, sorry).[/color]
              >
              >APD is a debugger, not a profiler. Thanks.[/color]

              "APD is the Advanced PHP Debugger. It was written to provide profiling and
              debugging capabilities for PHP code"

              And it goes on with an example of profiling later on the page.

              --
              Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
              http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

              Comment

              Working...