mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
merge from 5.5-mtr
This commit is contained in:
@ -33,6 +33,13 @@ sub mtr_exe_maybe_exists(@);
|
||||
sub mtr_milli_sleep($);
|
||||
sub start_timer($);
|
||||
sub has_expired($);
|
||||
sub init_timers();
|
||||
sub mark_time_used($);
|
||||
sub add_total_times($);
|
||||
sub print_times_used($$);
|
||||
sub print_total_times($);
|
||||
|
||||
our $opt_report_times;
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@ -205,4 +212,81 @@ sub start_timer ($) { return time + $_[0]; }
|
||||
|
||||
sub has_expired ($) { return $_[0] && time gt $_[0]; }
|
||||
|
||||
# Below code is for time usage reporting
|
||||
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
my %time_used= (
|
||||
'collect' => 0,
|
||||
'restart' => 0,
|
||||
'check' => 0,
|
||||
'ch-warn' => 0,
|
||||
'test' => 0,
|
||||
'init' => 0,
|
||||
);
|
||||
|
||||
my %time_text= (
|
||||
'collect' => "Collecting test cases",
|
||||
'restart' => "Server stop/start",
|
||||
'check' => "Check-testcase",
|
||||
'ch-warn' => "Check for warnings",
|
||||
'test' => "Test execution",
|
||||
'init' => "Initialization etc.",
|
||||
);
|
||||
|
||||
# Counts number of reports from workers
|
||||
|
||||
my $time_totals= 0;
|
||||
|
||||
my $last_timer_set;
|
||||
|
||||
sub init_timers() {
|
||||
$last_timer_set= gettimeofday();
|
||||
}
|
||||
|
||||
sub mark_time_used($) {
|
||||
my ($name)= @_;
|
||||
return unless $opt_report_times;
|
||||
die "Unknown timer $name" unless exists $time_used{$name};
|
||||
|
||||
my $curr_time= gettimeofday();
|
||||
$time_used{$name}+= int (($curr_time - $last_timer_set) * 1000 + .5);
|
||||
$last_timer_set= $curr_time;
|
||||
}
|
||||
|
||||
sub add_total_times($) {
|
||||
my ($dummy, $num, @line)= split (" ", $_[0]);
|
||||
|
||||
$time_totals++;
|
||||
foreach my $elem (@line) {
|
||||
my ($name, $spent)= split (":", $elem);
|
||||
$time_used{$name}+= $spent;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_times_used($$) {
|
||||
my ($server, $num)= @_;
|
||||
return unless $opt_report_times;
|
||||
|
||||
my $output= "SPENT $num";
|
||||
foreach my $name (keys %time_used) {
|
||||
my $spent= $time_used{$name};
|
||||
$output.= " $name:$spent";
|
||||
}
|
||||
print $server $output . "\n";
|
||||
}
|
||||
|
||||
sub print_total_times($) {
|
||||
# Don't print if we haven't received all worker data
|
||||
return if $time_totals != $_[0];
|
||||
|
||||
foreach my $name (keys %time_used)
|
||||
{
|
||||
my $spent= $time_used{$name}/1000;
|
||||
my $text= $time_text{$name};
|
||||
print ("Spent $spent seconds on $text\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -116,18 +116,20 @@ sub sleep_until_file_created ($$$) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
my $seconds= ($loop * $sleeptime) / 1000;
|
||||
|
||||
# Check if it died after the fork() was successful
|
||||
if ( defined $proc and ! $proc->wait_one(0) )
|
||||
{
|
||||
mtr_warning("Process $proc died");
|
||||
mtr_warning("Process $proc died after mysql-test-run waited $seconds " .
|
||||
"seconds for $pidfile to be created.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile");
|
||||
|
||||
# Print extra message every 60 seconds
|
||||
my $seconds= ($loop * $sleeptime) / 1000;
|
||||
if ( $seconds > 1 and int($seconds * 10) % 600 == 0 )
|
||||
if ( $seconds > 1 && int($seconds * 10) % 600 == 0 && $seconds < $timeout )
|
||||
{
|
||||
my $left= $timeout - $seconds;
|
||||
mtr_warning("Waited $seconds seconds for $pidfile to be created, " .
|
||||
@ -138,6 +140,8 @@ sub sleep_until_file_created ($$$) {
|
||||
|
||||
}
|
||||
|
||||
mtr_warning("Timeout after mysql-test-run waited $timeout seconds " .
|
||||
"for the process $proc to create a pid file.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user