mbligh | 5d9d9d6 | 2007-07-10 17:48:36 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Copyright Martin J. Bligh (mbligh@mbligh.org), 2006 |
| 4 | |
| 5 | ($file, $y_label, $columns, $title) = @ARGV; |
| 6 | die unless (-f $file); |
| 7 | die unless ($y_label); |
| 8 | die unless ($columns =~ /^1:\d+/); |
| 9 | |
| 10 | # print " ++++++ plotgraph $file\n"; |
| 11 | plotgraph($file, $y_label, $columns, $title); |
| 12 | # print " ++++++ plotgraph\n"; |
| 13 | |
| 14 | # First column must be kernel count, second kernel version, third is job number |
| 15 | # $columns spec is 1:y-value:y-stddev |
| 16 | sub plotgraph { |
| 17 | my ($file, $y_label, $columns, $title) = @_; |
| 18 | my @xtics; |
| 19 | |
| 20 | if (!$title) { |
| 21 | $title = $file; |
| 22 | $title =~ s#.*/##; |
| 23 | } |
| 24 | open (INDATA, $file); |
| 25 | open (DATA_MAIN, "> ${file}.main"); |
| 26 | open (DATA_MM, "> ${file}.mm"); |
| 27 | open (DATA_OTHER, "> ${file}.other"); |
| 28 | my $count; |
| 29 | while ($data = <INDATA>) { |
| 30 | chomp $data; |
| 31 | ($count, my $version, my $job) = split (/\s+/, $data); |
| 32 | $short_ver = $version; |
| 33 | $short_ver =~ s/\+.*/+p$job/; |
| 34 | push @xtics, "\"$short_ver\" $count"; |
| 35 | if ($version =~ /^2\.\d+\.\d+(\.\d+|-rc\d+)?(-git\d+)?$/) { |
| 36 | print DATA_MAIN "$data\n"; |
| 37 | $plot_main = "\"${file}.main\" using $columns title \"mainline\""; |
| 38 | } elsif ($version =~ /^2\.\d+\.\d+(-rc\d+)?-mm\d+$/) { |
| 39 | print DATA_MM "$data\n"; |
| 40 | $plot_mm = "\"${file}.mm\" using $columns title \"-mm\""; |
| 41 | } else { |
| 42 | print DATA_OTHER "$data\n"; |
| 43 | $plot_other = "\"${file}.other\" using $columns title \"other\""; |
| 44 | } |
| 45 | } |
| 46 | close (INDATA); |
| 47 | close (DATA_MAIN); |
| 48 | close (DATA_MM); |
| 49 | close (DATA_OTHER); |
| 50 | |
| 51 | die unless ($count > 0); |
| 52 | $x_res = $count * 12; |
| 53 | $y_res = 900; |
| 54 | push @plots, $plot_main if ($plot_main); |
| 55 | push @plots, $plot_mm if ($plot_mm); |
| 56 | push @plots, $plot_other if ($plot_other); |
| 57 | $plots = join (',', @plots); |
| 58 | |
| 59 | open (GNUPLOT, "> ${file}.gnuplot"); |
| 60 | # print "MACHINE: $machine\n"; |
| 61 | print GNUPLOT "set terminal png size $x_res,$y_res\n"; |
| 62 | print GNUPLOT "set key below\n"; |
| 63 | print GNUPLOT "set title \"$title\"\n"; |
| 64 | print GNUPLOT "set xlabel \"Kernel\"\n"; |
| 65 | print GNUPLOT "set ylabel \"${y_label}\"\n"; |
| 66 | print GNUPLOT "set output \"${file}.png\"\n"; |
| 67 | print GNUPLOT "set style data yerrorlines\n"; |
| 68 | print GNUPLOT "set grid\n"; |
| 69 | $xtics = join ',', @xtics; |
| 70 | print GNUPLOT "\nset xtics rotate (${xtics})\n\n"; |
| 71 | print GNUPLOT "plot $plots\n"; |
| 72 | print GNUPLOT "replot"; |
| 73 | close (GNUPLOT); |
| 74 | `/usr/bin/gnuplot ${file}.gnuplot`; |
| 75 | `chmod 644 ${file}.gnuplot`; |
| 76 | `chmod 644 ${file}.png`; |
| 77 | } |