From 28a1d576fa34c9c274f93b70d0e7aa993baa8e27 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 27 Oct 2014 12:35:12 +0100 Subject: [PATCH] script: fix display of ten slowest tests if < 10 tests are run. Note: $#array is the biggest index in an array in perl. @array evaluated in scalar context is the number of elements. Hence scalar(@array) = 1 + $#array Or equivalently: 0 + @array = 1 + $#array ... :-) Apart from this off-by-one error, the "unless" clause to trigger the capping of the number of tests listed was wrong. Hence if less then 10 tests were run, a number of blank lines were appended. Signed-off-by: Michael Adam --- script/show_testsuite_time | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/show_testsuite_time b/script/show_testsuite_time index 13ae0b6..d2bf5bc 100755 --- a/script/show_testsuite_time +++ b/script/show_testsuite_time @@ -40,7 +40,7 @@ while(<$fh>) } } my @sorted = sort { $hash{$b}<=>$hash{$a} } keys(%hash); -$max = $#sorted unless $max or ($max < $#sorted); +$max = @sorted if (($max <= 0) or ($max > @sorted)); for my $l (@sorted[0..($max - 1)]) { print $l."\n"; } -- 1.9.1