Add plot tools.
authorfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Wed, 25 Apr 2007 03:45:30 +0000 (03:45 +0000)
committerfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Wed, 25 Apr 2007 03:45:30 +0000 (03:45 +0000)
git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@977 959494ce-11ee-0310-bf91-de5d638817bd

clients/gaim/makeplot [new file with mode: 0755]
clients/gaim/statcomp [new file with mode: 0755]

diff --git a/clients/gaim/makeplot b/clients/gaim/makeplot
new file mode 100755 (executable)
index 0000000..5650722
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+rm -f plot-*
+
+./statcomp gstat | while read k x avg dev dl dh min max; do
+    echo "$x $dl $min $max $dh" >>plot-$k-dev; echo "$x $avg" >>plot-$k-avg
+done
+
+for k in au du; do
+    gnuplot <<EOF
+set xrange [0:10000]
+set terminal postscript eps enhanced
+set output "$k.ps"
+plot "plot-$k-dev" with candlesticks, "plot-$k-avg" with lines;
+EOF
+done
diff --git a/clients/gaim/statcomp b/clients/gaim/statcomp
new file mode 100755 (executable)
index 0000000..c0c35e7
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+$x = -1;
+$data = {};
+
+while(<>) {
+    if(/^(\d+):/) {
+       if($x != -1) {
+           for $k (keys %$data) {
+               $sum = $num = 0;
+               $min = $max = -1;
+               for $v (@{$data->{$k}}) {
+                   $sum += $v;
+                   $num++;
+                   if(($min == -1) || ($min > $v)) {
+                       $min = $v;
+                   }
+                   if(($max == -1) || ($max < $v)) {
+                       $max = $v;
+                   }
+               }
+               $avg = $sum / $num;
+               $devsum = 0;
+               for $v (@{$data->{$k}}) {
+                   $devsum += ($v - $avg) ** 2;
+               }
+               $dev = sqrt($devsum / $num);
+               $devmin = $avg - $dev;
+               $devmax = $avg + $dev;
+               print "$k $x $avg $dev $devmin $devmax $min $max\n";
+           }
+       }
+       $x = $1;
+       $data = {};
+    } elsif(/(\w+): ([\d.]+)/) {
+       push @{$data->{$1}}, $2;
+    }
+}