blob: c1b950dc34d804c98bb376c5f50d810b309841ce [file] [log] [blame]
Andrew Lenharth6e927292005-04-27 14:57:26 +00001#!/usr/bin/perl
2#take the output of parseNLT.pl and load it into a database
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +00003# use like: cat file |perl parseNLT.pl |perl importNLT.pl password
Andrew Lenharth6e927292005-04-27 14:57:26 +00004
5use DBI;
6
7# database information
8$db="llvmalpha";
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +00009$host="localhost";
Andrew Lenharth6e927292005-04-27 14:57:26 +000010$userid="llvmdbuser";
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000011$passwd=shift @ARGV;
Andrew Lenharth6e927292005-04-27 14:57:26 +000012$connectionInfo="dbi:mysql:$db;$host";
13
14# make connection to database
15$dbh = DBI->connect($connectionInfo,$userid,$passwd) or die DBI->errstr;
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000016my $sth = $dbh->prepare( q{
17 INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES (?, STR_TO_DATE(?, '\%d \%M \%Y'), ?, ?)
18 }) || die "Can't prepare statement: $DBI::errstr";;
Andrew Lenharth6e927292005-04-27 14:57:26 +000019
20while($d = <>)
21{
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000022 chomp $d;
23 if (18 == scalar split " ", $d)
Andrew Lenharth6e927292005-04-27 14:57:26 +000024 {
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000025 ($day, $mon, $year, $prog, $gccas, $bc, $llccompile, $llcbetacompile, $jitcompile,
Andrew Lenharthe3142be2005-04-27 17:32:41 +000026 $mc, $gcc, $cbe, $llc, $llcbeta, $jit, $foo1, $foo2, $foo3) = split " ", $d;
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000027 if ($gccas =~ /\d+/)
28 {
29 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
30 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'gccas', $gccas)") || die DBI->errstr;
31 }
32 if ($bc =~ /\d/)
33 {
34 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
35 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'bytecode', $bc)") || die DBI->errstr;
36 }
37 if ($llccompile =~ /\d/)
38 {
39 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
40 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'llc-compile', $llccompile)") || die DBI->errstr;
41 }
42 if ($llcbetacompile =~ /\d/)
43 {
44 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
45 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'llc-beta-compile', $llcbetacompile)") || die DBI->errstr;
46 }
47 if ($jitcompile =~ /\d/)
48 {
49 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
50 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'jit-compile', $jitcompile)") || die DBI->errstr;
51 }
52 if ($mc =~ /\d/)
53 {
54 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
55 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'machine-code', $mc)") || die DBI->errstr;
56 }
57 if ($gcc =~ /\d/)
58 {
59 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
60 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'gcc', $gcc)") || die DBI->errstr;
61 }
62 if ($llc =~ /\d/)
63 {
64 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
65 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'llc', $llc)") || die DBI->errstr;
66 }
67 if ($llcbeta =~ /\d/)
68 {
69 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
70 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'llc-beta', $llcbeta)") || die DBI->errstr;
71 }
72 if ($jit =~ /\d/)
73 {
74 $dbh->do("INSERT INTO Tests (NAME, RUN, TEST, VALUE) VALUES
75 ('$prog', STR_TO_DATE('$day $mon $year', '\%d \%M \%Y'), 'jit', $jit)") || die DBI->errstr;
76 }
77 print ".";
78 }
79 else
80 {
81 print "\nNO: $d\n";
Andrew Lenharth6e927292005-04-27 14:57:26 +000082 }
83}
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000084print "\n";
Andrew Lenharth6e927292005-04-27 14:57:26 +000085# disconnect from database
Andrew Lenharth91aa9ee2005-04-27 16:03:01 +000086$dbh->disconnect;