]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
Add script to convert CANalyzer logs to gnuplot-friendly histograms
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Feb 2011 12:27:56 +0000 (13:27 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Feb 2011 12:27:56 +0000 (13:27 +0100)
gw-tests/canalyzer/convall.pl [new file with mode: 0755]

diff --git a/gw-tests/canalyzer/convall.pl b/gw-tests/canalyzer/convall.pl
new file mode 100755 (executable)
index 0000000..62d3082
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+foreach $l(`find ../results -name '*.log'`) {
+    chomp $l;
+    $t = $l;
+    $t =~ s/.log$/.txt/;
+    system("./mdfconv $l > $t");
+
+    my %hist = ();
+    open(my $fh, '<', $t);
+    while (<$fh>) {
+       next if /^#/;
+       chomp;
+       @l1 = split / /, $_;
+       $_ = <$fh>;
+       chomp;
+       @l2 = split / /, $_;
+
+       $time10us = $l2[14]-$l1[14];
+#      if (exists $hist{$time10us}) {
+           $hist{$time10us} += 1;
+#      } else {
+#          $hist{$time10us} = 1;
+#      }
+    }
+    $cum = 0;
+    foreach $t(reverse(sort {$a <=> $b} keys(%hist))) {
+       $cum += $hist{$t};
+       $hist{$t} = $cum;
+    }
+
+    $h=$t;
+    $h =~ s/.txt$/-hist.txt/;
+    open(my $fhout, '>', $h);
+    print "$h\n";
+    foreach $t(sort {$a <=> $b} keys(%hist)) {
+       printf $fhout "%g %d\n", $t/100.0, $hist{$t};
+    }
+}
+exit 0