Changeset 4766


Ignore:
Timestamp:
11/07/08 04:07:19 (8 years ago)
Author:
werner
Message:
  • for better readability, output filled areas, not just lines
  • added option -o file.png to output the plot to a file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/wlan-perf/pingh

    r4757 r4766  
    2525 
    2626 
    27 die "usage: $0 ping_file" unless defined $ARGV[0]; 
     27$name = shift @ARGV; 
    2828 
    29 @t = &extract_ping($ARGV[0]); 
     29if ($name eq "-o") { 
     30    $out = shift @ARGV; 
     31    $name = shift @ARGV; 
     32} 
     33 
     34die "usage: $0 [-o out.png] ping_file" unless defined $name; 
     35 
     36@t = &extract_ping($name); 
     37$n = @t; 
    3038 
    3139$max = 0; 
    3240for (@t) { 
     41    $min = $_ if $min > $_ || !defined $min; 
    3342    $max = $_ if $max < $_; 
    3443} 
     44for ($low = 1; $low*10 <= $min; $low *= 10) {} 
    3545 
    36 $width = $ARGV[1]; 
     46$width = $ARGV[0]; 
    3747if (defined $width) { 
    3848    for (@t) { 
     
    4050    } 
    4151 
     52    print "0 0\n"; 
    4253    for ($i = 0; $i != @bin; $i++) { 
    43         print $width*($i+0.5), " ", 0+$bin[$i], "\n"; 
     54        print $width*($i+0.5), " ", $bin[$i]/$n*100, "\n"; 
    4455    } 
    4556} 
     
    4758    $mode = (stat(STDOUT))[2]; 
    4859    if (!S_ISFIFO($mode)) { 
    49         open(STDOUT, "|gnuplot -persist") || die "gnuplot: $!"; 
     60        open(STDOUT, "|gnuplot".(defined $out ? "" : " -persist")) || 
     61          die "gnuplot: $!"; 
    5062    } 
    5163 
     64    $style = "lines"; 
     65    $style = "filledcurves x1"; 
     66    if (defined $out) { 
     67        print "set terminal png\n"; 
     68        print "set output \"$out\"\n"; 
     69    } 
     70    print "set title '$name'\n"; 
     71    print "set xlabel 'Ping round-trip time (ms)'\n"; 
     72    print "set ylabel '% of samples ($n)'\n"; 
     73    print "set logscale x\n"; 
     74    print "set xrange [$low:$max]\n"; 
     75    print "set yrange [0:100]\n"; 
     76#    print "set fillstyle solid\n"; 
    5277    print "plot "; 
    53     for ($w = 1; $w < $max; $w *= 2) { 
    54         print ", " unless $w == 1; 
    55         print "\"< $0 $ARGV[0] $w\" with lines title \"$w\""; 
     78    for ($w = 1/16; $w < $max/2; $w *= 2) { 
     79        $legend = $w < 1 ? ($w*1000)."us" : "${w}ms"; 
     80        push(@c, "\"< $0 $name $w\" with $style title \"bin = $legend\""); 
    5681    } 
    57     print "\n"; 
     82    print join(",", reverse @c), "\n"; 
    5883} 
    5984 
Note: See TracChangeset for help on using the changeset viewer.