Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit 5ac8800b98b509dfa1ff36ca0b2dd24710603235 created 12 years 5 months ago. By Werner Almesberger, m1rc3/norruption/2/plot: analyze console log and plot probability distribution | |
---|---|
1 | #!/usr/bin/perl |
2 | $n = 1; |
3 | while (<>) { |
4 | next unless /^=== (\d+) ===/; |
5 | while ($1 != $n) { |
6 | push(@f, $n); |
7 | $n++; |
8 | } |
9 | $n++; |
10 | } |
11 | |
12 | $n--; |
13 | $f = int($n/@f+0.5); |
14 | |
15 | $last = 0; |
16 | for (@f) { |
17 | push(@d, $_-$last); |
18 | $last = $_; |
19 | } |
20 | |
21 | $cmd = "|gnuplot -e '". |
22 | 'set term postscript color eps enhanced solid lw 2 20;'. |
23 | 'set output "out.eps";'. |
24 | 'set title "Probability distribution of time between NOR corruptions";'. |
25 | 'set xlabel "Power cycles";'. |
26 | 'set ylabel "Cumulative probability";'. |
27 | 'set key bottom;'. |
28 | 'plot "-" with lines title "Corruptions observed (N='.@f.')", '. |
29 | '1-exp(-'.1/$f.'*x) with lines lt 3 '. |
30 | 'title "Exponential distribution ({/Symbol l}=1/'.$f.')"'. |
31 | "'"; |
32 | |
33 | open(PIPE, $cmd) || die "open: $!"; |
34 | $i = 0; |
35 | for (sort { $a <=> $b } @d) { |
36 | $i++; |
37 | print PIPE $_, " ", $i/@f, "\n"; |
38 | } |
39 | close(PIPE) || die "close: $!"; |
40 | |
41 | system("cat out.eps | ". |
42 | "gs -sDEVICE=ppmraw -r100 -sOutputFile=- ". |
43 | "-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sPAPERSIZE=a4 -q - | ". |
44 | "convert -trim - out.png"); |
45 | unlink("out.eps"); |
46 |
Branches:
master