blob: d9b61d813f90ae3ef4c3f1885773bc84d1d95239 [file] [log] [blame]
Andrew Lenharthe5dc5c92005-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";
30
31print CMDSTREAM "set terminal png\n";
32print CMDSTREAM "set output\n";
33print CMDSTREAM "set xdata time\n";
34print CMDSTREAM 'set timefmt "%Y-%m-%d"';
35print CMDSTREAM "\nplot";
36for ($iter = 0; $iter < $count; $iter++) {
37 if ($iter)
38 { print CMDSTREAM ","; }
39 print CMDSTREAM " '-' using 1:2 with lines";
40}
41
42print CMDSTREAM "\n";
43
44for ($iter = 0; $iter < $count; $iter++) {
45
46 $prog = $q->param('n' . $iter);
47 $test = $q->param('t' . $iter);
48
49 $query = "Select RUN, VALUE from Tests where TEST = '$test' AND NAME = '$prog' ORDER BY RUN";
50 #print "\n$query\n";
51
52 my $sth = $dbh->prepare( $query) || die "Can't prepare statement: $DBI::errstr";;
53
54 my $rc = $sth->execute or die DBI->errstr;
55
56 while(($da,$v) = $sth->fetchrow_array)
57 {
58 print CMDSTREAM "$da $v\n";
59 }
60
61 print CMDSTREAM "e\n";
62}
63print CMDSTREAM "exit\n";
64close CMDSTREAM;
65
66# disconnect from database
67$dbh->disconnect;