| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl | 
 | 2 | #take the output of parseNLT.pl and load it into a database | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 3 | # use like: cat file |perl parseNLT.pl |perl importNLT.pl password | 
| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 4 |  | 
 | 5 | use DBI; | 
 | 6 |  | 
 | 7 | # database information | 
 | 8 | $db="llvmalpha"; | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 9 | $host="localhost"; | 
| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 10 | $userid="llvmdbuser"; | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 11 | $passwd=shift @ARGV; | 
| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 12 | $connectionInfo="dbi:mysql:$db;$host"; | 
 | 13 |  | 
 | 14 | # make connection to database | 
 | 15 | $dbh = DBI->connect($connectionInfo,$userid,$passwd) or die DBI->errstr; | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 16 | my $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 Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 19 |  | 
 | 20 | while($d = <>) | 
 | 21 | { | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 22 |   chomp $d; | 
 | 23 |   if (18 == scalar split " ", $d) | 
| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 24 |     { | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 25 |       ($day, $mon, $year, $prog, $gccas, $bc, $llccompile, $llcbetacompile, $jitcompile, | 
| Andrew Lenharth | e3142be | 2005-04-27 17:32:41 +0000 | [diff] [blame] | 26 |        $mc, $gcc, $cbe, $llc, $llcbeta, $jit, $foo1, $foo2, $foo3) = split " ", $d; | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 27 |       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 Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 82 |     } | 
 | 83 | } | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 84 | print "\n"; | 
| Andrew Lenharth | 6e92729 | 2005-04-27 14:57:26 +0000 | [diff] [blame] | 85 | # disconnect from database | 
| Andrew Lenharth | 91aa9ee | 2005-04-27 16:03:01 +0000 | [diff] [blame] | 86 | $dbh->disconnect; |