Skip to content

Commit

Permalink
Factor analyze_timings_files() out of analyze MAIN()
Browse files Browse the repository at this point in the history
  • Loading branch information
japhb committed May 14, 2013
1 parent 796439f commit d58e086
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions analyze
Expand Up @@ -34,27 +34,7 @@ sub MAIN {
or die "Could not open outfile '$out': $!";

# Analyze results
my $time_type = $main_opt->{'ignore-startup'} ? 'cooked' : 'best';
my $analyze_timing_data = sub {
my $data = shift;

for my $test (@{$data->{times}}) {
$test->{compare} = compare_times($test->{$time_type});
}

$formatter->($data, $main_opt, $out_fh);
};

if ($main_opt->{compare}) {
my $merged = merge_timing_files(@ARGV);
$analyze_timing_data->($merged);
}
else {
for my $timing_file (@ARGV) {
my $data = load_timing_file($timing_file);
$analyze_timing_data->($data);
}
}
analyze_timings_files($main_opt, $out_fh, @ARGV);
}

sub process_options_and_arguments {
Expand Down Expand Up @@ -85,6 +65,32 @@ sub process_options_and_arguments {
return \%opt;
}

sub analyze_timings_files {
my ($opt, $out_fh, @files) = @_;

my $time_type = $opt->{'ignore-startup'} ? 'cooked' : 'best';
my $analyze_timing_data = sub {
my $data = shift;

for my $test (@{$data->{times}}) {
$test->{compare} = compare_times($test->{$time_type});
}

$opt->{formatter}->($data, $opt, $out_fh);
};

if ($opt->{compare}) {
my $merged = merge_timing_files(@files);
$analyze_timing_data->($merged);
}
else {
for my $timing_file (@files) {
my $data = load_timing_file($timing_file);
$analyze_timing_data->($data);
}
}
}

sub merge_timing_files {
my (%times, %compilers);
my (@test_order, @groups);
Expand Down

0 comments on commit d58e086

Please sign in to comment.