]> rtime.felk.cvut.cz Git - can-benchmark.git/blob - gw-tests/canalyzer/convall.pl
Add script to convert CANalyzer logs to gnuplot-friendly histograms
[can-benchmark.git] / gw-tests / canalyzer / convall.pl
1 #!/usr/bin/perl -w
2
3 foreach $l(`find ../results -name '*.log'`) {
4     chomp $l;
5     $t = $l;
6     $t =~ s/.log$/.txt/;
7     system("./mdfconv $l > $t");
8
9     my %hist = ();
10     open(my $fh, '<', $t);
11     while (<$fh>) {
12         next if /^#/;
13         chomp;
14         @l1 = split / /, $_;
15         $_ = <$fh>;
16         chomp;
17         @l2 = split / /, $_;
18
19         $time10us = $l2[14]-$l1[14];
20 #       if (exists $hist{$time10us}) {
21             $hist{$time10us} += 1;
22 #       } else {
23 #           $hist{$time10us} = 1;
24 #       }
25     }
26     $cum = 0;
27     foreach $t(reverse(sort {$a <=> $b} keys(%hist))) {
28         $cum += $hist{$t};
29         $hist{$t} = $cum;
30     }
31
32     $h=$t;
33     $h =~ s/.txt$/-hist.txt/;
34     open(my $fhout, '>', $h);
35     print "$h\n";
36     foreach $t(sort {$a <=> $b} keys(%hist)) {
37         printf $fhout "%g %d\n", $t/100.0, $hist{$t};
38     }
39 }
40 exit 0