r4766 - developers/werner/wlan-perf

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Nov 7 05:07:19 CET 2008


Author: werner
Date: 2008-11-07 05:07:19 +0100 (Fri, 07 Nov 2008)
New Revision: 4766

Modified:
   developers/werner/wlan-perf/pingh
Log:
- for better readability, output filled areas, not just lines
- added option  -o file.png  to output the plot to a file



Modified: developers/werner/wlan-perf/pingh
===================================================================
--- developers/werner/wlan-perf/pingh	2008-11-07 03:50:29 UTC (rev 4765)
+++ developers/werner/wlan-perf/pingh	2008-11-07 04:07:19 UTC (rev 4766)
@@ -24,36 +24,61 @@
 }
 
 
-die "usage: $0 ping_file" unless defined $ARGV[0];
+$name = shift @ARGV;
 
- at t = &extract_ping($ARGV[0]);
+if ($name eq "-o") {
+    $out = shift @ARGV;
+    $name = shift @ARGV;
+}
 
+die "usage: $0 [-o out.png] ping_file" unless defined $name;
+
+ at t = &extract_ping($name);
+$n = @t;
+
 $max = 0;
 for (@t) {
+    $min = $_ if $min > $_ || !defined $min;
     $max = $_ if $max < $_;
 }
+for ($low = 1; $low*10 <= $min; $low *= 10) {}
 
-$width = $ARGV[1];
+$width = $ARGV[0];
 if (defined $width) {
     for (@t) {
 	$bin[int($_/$width)]++;
     }
 
+    print "0 0\n";
     for ($i = 0; $i != @bin; $i++) {
-	print $width*($i+0.5), " ", 0+$bin[$i], "\n";
+	print $width*($i+0.5), " ", $bin[$i]/$n*100, "\n";
     }
 }
 else {
     $mode = (stat(STDOUT))[2];
     if (!S_ISFIFO($mode)) {
-	open(STDOUT, "|gnuplot -persist") || die "gnuplot: $!";
+	open(STDOUT, "|gnuplot".(defined $out ? "" : " -persist")) ||
+	  die "gnuplot: $!";
     }
 
+    $style = "lines";
+    $style = "filledcurves x1";
+    if (defined $out) {
+	print "set terminal png\n";
+	print "set output \"$out\"\n";
+    }
+    print "set title '$name'\n";
+    print "set xlabel 'Ping round-trip time (ms)'\n";
+    print "set ylabel '% of samples ($n)'\n";
+    print "set logscale x\n";
+    print "set xrange [$low:$max]\n";
+    print "set yrange [0:100]\n";
+#    print "set fillstyle solid\n";
     print "plot ";
-    for ($w = 1; $w < $max; $w *= 2) {
-	print ", " unless $w == 1;
-	print "\"< $0 $ARGV[0] $w\" with lines title \"$w\"";
+    for ($w = 1/16; $w < $max/2; $w *= 2) {
+	$legend = $w < 1 ? ($w*1000)."us" : "${w}ms";
+	push(@c, "\"< $0 $name $w\" with $style title \"bin = $legend\"");
     }
-    print "\n";
+    print join(",", reverse @c), "\n";
 }
 




More information about the commitlog mailing list