Changeset 365


Ignore:
Timestamp:
Mar 18, 2010, 1:00:26 PM (11 years ago)
Author:
zerodeux
Message:

Gave up with 'inc' measure and display, mostly useless right now

Location:
phptop
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • phptop/NEWS

    r364 r365  
    11phptop 0.5 - Unreleased
    22
     3    * Gave up 'inc' measure and display; it could be seen as a code complexity
     4      measure but has been merely useless in production use for the last months
    35    * New -o|--output-mode option, refactored reporting internally
    46    * Showing sorting column with '>' on text output
  • phptop/phptop

    r364 r365  
    4444
    4545# Globals
    46 my @keys = qw/hit time user sys mem mem_max inc inc_max/;
     46my @keys = qw/hit time user sys mem mem_max/;
    4747my %stat;
    4848my $now   = time();
     
    7070  -o, --output mode    Output mode: text or html (default is $output);
    7171  -p, --path-only      Only print path, skip http://host
    72   -s, --sort key       Sort key: hit, time, user, sys, mem or inc (default is @sortkeys)
     72  -s, --sort key       Sort key: hit, time, user, sys or mem (default is @sortkeys)
    7373  -t, --time N         Consider log events from now back to N minutes (default is $span)
    7474  -v, --version        Display version number and copyright info
     
    8383  Mem/hit   Average allocated memory per query (MB/hit)
    8484  Mem_max   Maximum allocated memory across queries (MB)
    85   Inc/hit   Average included files per query
    86   Inc_max   Maximum included files across queries
    8785EOF
    8886    exit 0;
     
    162160            $stat{$url}{$key} += $val;
    163161
    164             # Compute max for some values (mem, inc)
     162            # Compute max for mem values
    165163            if ($key eq 'mem') {
    166164                $stat{$url}{'mem_max'} = $val if ($stat{$url}{'mem_max'} || 0) < $val;
    167165            }
    168             elsif ($key eq 'inc') {
    169                 $stat{$url}{'inc_max'} = $val if ($stat{$url}{'inc_max'} || 0) < $val;
    170             }
    171166        }
    172167
     
    180175
    181176sub fix_stat {
    182     # Convert 'mem'  and 'inc' values from total to 'per hit', more useful and meaningful
    183177    while (my ($url, $i) = each %stat) {
    184         $i->{'mem_max'} /= 2**20;            # Also scale memory values from bytes to MB
    185         $i->{'mem'} /= $i->{'hit'} * 2**20;  # Idem
    186         $i->{'inc'} /= $i->{'hit'};
     178        # Convert 'mem' values from total to 'per hit' average, more meaningful.
     179        # Also scale memory values from bytes to MB.
     180        $i->{'mem'} /= $i->{'hit'} * 2**20;
     181        $i->{'mem_max'} /= 2**20;
    187182    }
    188183}
     
    193188    my @headers = map {
    194189        my $h = $_;
    195         $h = "$h/hit" if /^(mem|inc)$/;  # Mem and Inc are per-hit values
     190        $h = "$h/hit" if /^mem$/;  # Mem shows per-hit average values
    196191        ucfirst $h;
    197192    } @keys;
     
    210205        next if @rows >= $count;
    211206
    212         my @cells = map { sprintf($_ =~ m/hit|inc/ ? '%d' : '%.1f', $s->{$_}) } @keys;
     207        my @cells = map { sprintf($_ =~ m/hit/ ? '%d' : '%.1f', $s->{$_}) } @keys;
    213208        push(@rows, [ $url, @cells]);
    214209    }
    215210
    216     my @sums = map { defined $sum{$_} ? sprintf($_ =~ m/hit|inc/ ? '%d' : '%.1f', $sum{$_}) : '' } @keys;
     211    my @sums = map { defined $sum{$_} ? sprintf($_ =~ m/hit/ ? '%d' : '%.1f', $sum{$_}) : '' } @keys;
    217212    unshift(@sums, "Total (from last $span min)");
    218213
  • phptop/phptop_hook.php

    r264 r365  
    4444  $mem   = memory_get_peak_usage(TRUE);
    4545
    46   $inc   = count(get_included_files());
    47 
    4846  $proto = isset($_SERVER['HTTPS']) ? 'https' : 'http';
    4947  $vhost = $_SERVER['SERVER_NAME'];
     
    5149  $self  = $vhost != '' ? "$proto://$vhost$uri" : $_SERVER['SCRIPT_FILENAME'];
    5250
    53   $msg = sprintf("phptop %s time:%.6F user:%.6F sys:%.6F mem:%g inc:%g", $self, $time, $tusr, $tsys, $mem, $inc);
     51  $msg = sprintf("phptop %s time:%.6F user:%.6F sys:%.6F mem:%g", $self, $time, $tusr, $tsys, $mem);
    5452  error_log($msg);
    5553}
Note: See TracChangeset for help on using the changeset viewer.