summaryrefslogtreecommitdiff
path: root/tko/plotgraph
blob: 21de62bcf16eb3353531873b56c0f88584761694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl 
# 
# Copyright Martin J. Bligh (mbligh@mbligh.org), 2006

($file, $y_label, $columns, $title) = @ARGV;
die unless (-f $file);
die unless ($y_label);
die unless ($columns =~ /^1:\d+/);

# print " ++++++ plotgraph $file\n";
plotgraph($file, $y_label, $columns, $title);
# print " ++++++ plotgraph\n";

# First column must be kernel count, second kernel version, third is job number
# $columns spec is 1:y-value:y-stddev
sub plotgraph {
    my ($file, $y_label, $columns, $title) = @_;
    my @xtics;

    if (!$title) {
        $title = $file;
        $title =~ s#.*/##;
    }
    open (INDATA, $file);
    open (DATA_MAIN, "> ${file}.main");
    open (DATA_MM, "> ${file}.mm");
    open (DATA_OTHER, "> ${file}.other");
    my $count;
    while ($data = <INDATA>) {
        chomp $data;
        ($count, my $version, my $job) = split (/\s+/, $data);
        $short_ver = $version;
        $short_ver =~ s/\+.*/+p$job/;
        push @xtics, "\"$short_ver\" $count";
        if ($version =~ /^2\.\d+\.\d+(\.\d+|-rc\d+)?(-git\d+)?$/) {
            print DATA_MAIN "$data\n";
            $plot_main = "\"${file}.main\" using $columns title \"mainline\"";
        } elsif ($version =~ /^2\.\d+\.\d+(-rc\d+)?-mm\d+$/) {
            print DATA_MM "$data\n";
            $plot_mm = "\"${file}.mm\" using $columns title \"-mm\"";
        } else {
            print DATA_OTHER "$data\n";
            $plot_other = "\"${file}.other\" using $columns title \"other\"";
        }
    }
    close (INDATA);
    close (DATA_MAIN);
    close (DATA_MM);
    close (DATA_OTHER);

    die unless ($count > 0);
    $x_res = $count * 12;
    $y_res = 900;
    push @plots, $plot_main if ($plot_main);
    push @plots, $plot_mm if ($plot_mm);
    push @plots, $plot_other if ($plot_other);
    $plots = join (',', @plots);

    open (GNUPLOT, "> ${file}.gnuplot");
    # print "MACHINE: $machine\n";
    print GNUPLOT "set terminal png size $x_res,$y_res\n";
    print GNUPLOT "set key below\n";
    print GNUPLOT "set title \"$title\"\n";
    print GNUPLOT "set xlabel \"Kernel\"\n";
    print GNUPLOT "set ylabel \"${y_label}\"\n";
    print GNUPLOT "set output \"${file}.png\"\n";
    print GNUPLOT "set style data yerrorlines\n";
    print GNUPLOT "set grid\n";
    $xtics = join ',', @xtics;
    print GNUPLOT "\nset xtics rotate (${xtics})\n\n";
    print GNUPLOT "plot $plots\n";
    print GNUPLOT "replot";
    close (GNUPLOT);
    `/usr/bin/gnuplot ${file}.gnuplot`;
    `chmod 644 ${file}.gnuplot`;
    `chmod 644 ${file}.png`;
}