11 my ($fh, $callback)= @_;
15 my ($run_index, $counter_index, $fixed_count);
20 if (/^T: (.*?)( \{(.*?)\})?( \[(.*?)(;.*?)?\])? I=([0-9]+)( U=([0-9]+))?$/) {
21 $callback->($current) if defined($current);
22 $current= { MINOR
=> $1,
26 $current->{VARIANT
}= $3 if defined($3);
28 $current->{PARAM1
}= $5;
29 $current->{PARAM2
}= substr($6, 1) if defined($6);
31 $current->{WORKUNITS
}= $9 if defined($9);
35 elsif (/^ Seconds: ([0-9]+\.[0-9]+)(( [-+][0-9]+\.[0-9]+)*)$/)
37 $current->{ELAPSED
}= [$1];
38 push @
{$current->{ELAPSED
}}, $1 + $_ for (split(" ", $2));
40 elsif (/^ (F: |V[0-9]:| ) ([^ ]+)\s+([0-9]+)((\s+[-+][0-9]+)*)$/)
42 my ($hdr, $name, $count, $deltas)= ($1, $2, $3, $4);
43 if ($hdr eq 'F: ' || ($hdr eq ' ' && !defined($run_index)))
46 $current->{LIST
}[$idx][$counter_index]= {NAME
=> $name,
48 for (split(" ", $deltas))
51 $current->{LIST
}[$idx][$counter_index]= {NAME
=> $name,
52 COUNT
=> $count + $_ };
55 $fixed_count= $counter_index;
59 if ($hdr =~ /^V([0-9]):$/)
62 $counter_index= $fixed_count;
65 $current->{LIST
}[$run_index][$counter_index]= { NAME
=> $name,
72 $callback->($current) if defined($current);
76 my ($dbh, $e, $suite_id, $major)= @_;
81 INSERT INTO perf_test_run(suite_run_id, test_major, test_minor, param1, param2,
82 variant, iterations, workunits)
83 VALUES (?, ?, ?, ?, ?, ?, ?, ?)
85 $dbh->do($sql, undef, $suite_id, $major, $e->{MINOR
}, $e->{PARAM1
}, $e->{PARAM2
},
86 $e->{VARIANT
}, $e->{ITERATIONS
}, $e->{WORKUNITS
});
87 # my $test_run_id= $dbh->{mysql_inserid};
88 my $test_run_id= $dbh->selectall_arrayref("SELECT LAST_INSERT_ID()")->[0][0];
90 $sql= "INSERT INTO perf_wallclock(test_run_id, instance_idx, secs) VALUES";
93 for (my $idx= 0; $idx < @
{$e->{ELAPSED
}}; $idx++)
95 $sql.= $sep ." (?, ?, ?)";
97 push @values, $test_run_id, $idx, $e->{ELAPSED
}[$idx];
99 $dbh->do($sql, undef, @values);
101 $sql= "INSERT INTO perf_counts(test_run_id, instance_idx, counter_idx, counter_name, counter_value) VALUES";
104 for (my $run_idx= 0; $run_idx < @
{$e->{LIST
}}; $run_idx++)
106 for (my $counter_idx= 0; $counter_idx < @
{$e->{LIST
}[$run_idx]}; $counter_idx++)
108 $sql.= $sep ." (?, ?, ?, ?, ?)";
110 push @values, $test_run_id, $run_idx, $counter_idx,
111 $e->{LIST
}[$run_idx][$counter_idx]{NAME
},
112 $e->{LIST
}[$run_idx][$counter_idx]{COUNT
};
115 $dbh->do($sql, undef, @values);
123 my $hostname= Sys
::Hostname
::hostname
();
125 my $os= qx{uname
-o
};
127 my $kernel= qx{uname
-r
};
129 my $arch= qx{uname
-m
};
131 my $cpu_name= "<unknown>";
132 my $cpu_mhz= "<unknown>";
133 if (open(FH
, '<', '/proc/cpuinfo'))
137 $cpu_name= $1 if /^model name\s* : (.*)$/;
138 $cpu_mhz= $1 if /^cpu MHz\s* : (.*)$/;
139 # For multicore we will get multiple hits, but it doesn't really matter.
147 WHERE hostname = ? AND os = ? AND kernel = ? AND arch = ? AND cpu_name = ? AND cpu_mhz = ?
149 my $res= $dbh->selectall_arrayref($sql, undef,
150 $hostname, $os, $kernel, $arch, $cpu_name, $cpu_mhz);
151 return $res->[0][0] if ($res && @
$res);
153 # Not there already, so need to insert a new one.
155 INSERT INTO perf_host (hostname, os, kernel, arch, cpu_name, cpu_mhz)
156 VALUES (?, ?, ?, ?, ?, ?)
158 $dbh->do($sql, undef, $hostname, $os, $kernel, $arch, $cpu_name, $cpu_mhz);
159 #my $shost_id= $dbh->{mysql_inserid};
160 my $host_id= $dbh->selectall_arrayref("SELECT LAST_INSERT_ID()")->[0][0];
165 my $rev= qx{git
-rev
-list HEAD
^..HEAD
};
170 # Check for local uncommitted modifications.
171 system("git-diff", "--quiet");
172 $rev= "* ". $rev if $?
;
182 sub get_suite_run_id
{
185 my $host_id= get_host_id
($dbh);
186 my $git_rev= get_git_rev
();
187 $dbh->do("INSERT INTO perf_suite_run(dt, code_rev, host_id) VALUES (NOW(), ?, ?)",
188 undef, $git_rev, $host_id);
189 #my $suite_run_id= $dbh->{mysql_inserid};
190 my $suite_run_id= $dbh->selectall_arrayref("SELECT LAST_INSERT_ID()")->[0][0];
191 return $suite_run_id;
195 my ($host, $user, $pass)= @ARGV;
197 my $dbh= DBI
->connect("dbi:mysql:database=beedb;host=$host", $user, $pass,
198 { RaiseError
=> 1, PrintError
=> 0 });
200 my $test_list= [glob('*.t')];
202 exit 0 unless @
$test_list;
204 my $suite_run_id= get_suite_run_id
($dbh);
206 for my $test (@
$test_list)
208 my $test_major= substr($test, 0, -2);
210 open CHILD
, "./$test|"
211 or die "Failed to spawn child '$test': $!\n";
212 print "Running test '$test'...\n";
213 parse_output
(\
*CHILD
, sub { insert_in_db
($dbh, $_[0], $suite_run_id, 'bitcopy'); });