blob: 0360e4120d8cdebb9d4dcc28ea218d0aadc12046 [file] [log] [blame]
Andrew Lenharth24d77502005-05-20 17:33:42 +00001#!/usr/bin/perl
2#takes a test and a program from a dp and produces a gnuplot script
3#use like perl plotNLT.pl password Programs/MultiSource/Benchmarks/ASCI_Purple/SMG2000/smg2000 llc
4
5use CGI;
6use DBI;
7my $q = new CGI;
8
9# database information
10$db="llvmalpha";
11$host="localhost";
12$userid="llvmdbuser";
13$passwd=$q->param('pwd');
14$connectionInfo="dbi:mysql:$db;$host";
15
16# make connection to database
17$dbh = DBI->connect($connectionInfo,$userid,$passwd) or die DBI->errstr;
18
19
20$count = 0;
21while ($q->param('n' . $count))
22 {
23 $count++;
24 }
25
26$| = 1;
27print "Content-type: image/png", "\n\n";
28
29open CMDSTREAM, "|gnuplot";
Andrew Lenharthedd47f22005-05-20 17:50:51 +000030#open CMDSTREAM, "|echo";
Andrew Lenharth24d77502005-05-20 17:33:42 +000031
32print CMDSTREAM "set terminal png\n";
33print CMDSTREAM "set output\n";
34print CMDSTREAM "set xdata time\n";
35print CMDSTREAM 'set timefmt "%Y-%m-%d"';
36print CMDSTREAM "\nplot";
37for ($iter = 0; $iter < $count; $iter++) {
38 if ($iter)
39 { print CMDSTREAM ","; }
Andrew Lenharthedd47f22005-05-20 17:50:51 +000040 print CMDSTREAM " '-' using 1:2 title \"" . $q->param('t' . $iter) . "," . $q->param('n' . $iter) . "\"with lines";
Andrew Lenharth24d77502005-05-20 17:33:42 +000041}
42
43print CMDSTREAM "\n";
44
45for ($iter = 0; $iter < $count; $iter++) {
46
47 $prog = $q->param('n' . $iter);
48 $test = $q->param('t' . $iter);
49
50 $query = "Select RUN, VALUE from Tests where TEST = '$test' AND NAME = '$prog' ORDER BY RUN";
51 #print "\n$query\n";
52
53 my $sth = $dbh->prepare( $query) || die "Can't prepare statement: $DBI::errstr";;
54
55 my $rc = $sth->execute or die DBI->errstr;
56
57 while(($da,$v) = $sth->fetchrow_array)
58 {
59 print CMDSTREAM "$da $v\n";
60 }
61
62 print CMDSTREAM "e\n";
63}
64print CMDSTREAM "exit\n";
65close CMDSTREAM;
66
67# disconnect from database
68$dbh->disconnect;