diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-05-15 11:02:06 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-05-15 11:02:06 +0200 |
commit | 2531355bd6c7020904e889164efde3a5bb19631f (patch) | |
tree | bfd16daed41333f4d15629db89b4d6afa5132f70 /lib/MIMOSA/Log.pm | |
parent | ed9ac7c472f724d76e07661f9c2e3084240786a7 (diff) |
perltidy
Diffstat (limited to 'lib/MIMOSA/Log.pm')
-rw-r--r-- | lib/MIMOSA/Log.pm | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/lib/MIMOSA/Log.pm b/lib/MIMOSA/Log.pm index 90e3a3b..270bbb2 100644 --- a/lib/MIMOSA/Log.pm +++ b/lib/MIMOSA/Log.pm @@ -171,28 +171,34 @@ sub merge { # which wasn't detected earlier because of duplicate triggers elsewhere. my $data_idx = 0; for my $run ( @{ $self->{log}{traces} } ) { - my $prev_elem = {name => q{}}; + my $prev_elem = { name => q{} }; for my $trace_elem ( @{ $run->{trace} } ) { my $log_elem = $data->{trace}[$data_idx]; - if ($log_elem->{isa} eq 'state' - and $trace_elem->{name} ne 'UNINITIALIZED' - and $log_elem->{us} > $self->{setup}{state_duration} * 1500 - and $prev_elem->{name} ne 'txDone' - and $prev_elem->{name} ne 'rxDone' - and $prev_elem->{name} ne 'epilogue') { - return sprintf('State %s (trigger index %d) took %.1f ms longer than expected', - $trace_elem->{name}, $data_idx, - ($log_elem->{us} / 1000) - $self->{setup}{state_duration} + if ( $log_elem->{isa} eq 'state' + and $trace_elem->{name} ne 'UNINITIALIZED' + and $log_elem->{us} > $self->{setup}{state_duration} * 1500 + and $prev_elem->{name} ne 'txDone' + and $prev_elem->{name} ne 'rxDone' + and $prev_elem->{name} ne 'epilogue' ) + { + return sprintf( +'State %s (trigger index %d) took %.1f ms longer than expected', + $trace_elem->{name}, + $data_idx, + ( $log_elem->{us} / 1000 ) - $self->{setup}{state_duration} ); } - if ($log_elem->{isa} eq 'state' - and $trace_elem->{name} ne 'UNINITIALIZED' - and $trace_elem->{name} ne 'TX' - and $trace_elem->{name} ne 'RX' - and $log_elem->{us} < $self->{setup}{state_duration} * 500 ) { - return sprintf('State %s (trigger index %d) was %.1f ms shorter than expected', - $trace_elem->{name}, $data_idx, - $self->{setup}{state_duration} - ($log_elem->{us} / 1000) + if ( $log_elem->{isa} eq 'state' + and $trace_elem->{name} ne 'UNINITIALIZED' + and $trace_elem->{name} ne 'TX' + and $trace_elem->{name} ne 'RX' + and $log_elem->{us} < $self->{setup}{state_duration} * 500 ) + { + return sprintf( +'State %s (trigger index %d) was %.1f ms shorter than expected', + $trace_elem->{name}, + $data_idx, + $self->{setup}{state_duration} - ( $log_elem->{us} / 1000 ) ); } $prev_elem = $trace_elem; @@ -237,12 +243,12 @@ sub preprocess { } for my $i ( 0 .. $#{ $self->{mim_results} } ) { - my $file = $self->{mim_results}[$i]; + my $file = $self->{mim_results}[$i]; my $error = $self->merge("${tmpdir}/${file}"); if ($error) { say "${file}: ${error}"; - push(@errmap, $i); + push( @errmap, $i ); } } @@ -308,27 +314,29 @@ sub validate { //= $run->{trace}[ $i - 1 ]{parameter}; } } + # online durations count current state + next transition, but we # only want to analyze current state -> substract next transition. # Note that we can only do this on online data which has # corresponding offline data, i.e. where the offline data was not # erroneous for my $run ( @{ $json->{traces} } ) { - if (exists $run->{total_energy}) { + if ( exists $run->{total_energy} ) { + # splice changes the array (and thus the indices). so we need to # start removing elements at the end - for my $erridx (reverse @errmap) { - splice(@{$run->{total_energy}}, $erridx, 1); + for my $erridx ( reverse @errmap ) { + splice( @{ $run->{total_energy} }, $erridx, 1 ); } } for my $i ( 0 .. $#{ $run->{trace} } ) { - for my $erridx (reverse @errmap) { - splice(@{$run->{trace}[$i]{online}}, $erridx, 1); + for my $erridx ( reverse @errmap ) { + splice( @{ $run->{trace}[$i]{online} }, $erridx, 1 ); } - if ($run->{trace}[$i]{isa} eq 'state') { - for my $j (0 .. $#{ $run->{trace}[$i]{online} } ) { - $run->{trace}[$i]{online}[$j]{time} -= - $run->{trace}[$i+1]{offline}[$j]{us}; + if ( $run->{trace}[$i]{isa} eq 'state' ) { + for my $j ( 0 .. $#{ $run->{trace}[$i]{online} } ) { + $run->{trace}[$i]{online}[$j]{time} + -= $run->{trace}[ $i + 1 ]{offline}[$j]{us}; } } } |