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