summaryrefslogtreecommitdiff
path: root/Echolot/Stats.pm
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-06-09 22:52:51 +0000
committerPeter Palfrader <peter@palfrader.org>2003-06-09 22:52:51 +0000
commit369253a2651e60a89baac2f412265e45a14739e4 (patch)
tree10eceff8ddc75aca3daef81491a417f9ccc3aa88 /Echolot/Stats.pm
parent5ef4b9d4d35b7811c5688d1cfb224ae2d9c2b750 (diff)
Bug fixes
Diffstat (limited to 'Echolot/Stats.pm')
-rw-r--r--Echolot/Stats.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm
index c7255c7..15609e7 100644
--- a/Echolot/Stats.pm
+++ b/Echolot/Stats.pm
@@ -1,7 +1,7 @@
package Echolot::Stats;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Stats.pm,v 1.57 2003/06/06 11:27:59 weasel Exp $
+# $Id: Stats.pm,v 1.58 2003/06/09 22:52:51 weasel Exp $
#
=pod
@@ -186,11 +186,12 @@ sub build_list2_capsstr($) {
sub median($) {
my ($arr) = @_;
+
my $cnt = scalar @$arr;
if ($cnt == 0) {
return undef;
} elsif ($cnt % 2 == 0) {
- return ($arr->[ int(($cnt - 1 ) / 2) ] + $arr->[ int($cnt / 2) ] ) / 2;
+ return (($arr->[ int(($cnt - 1 ) / 2) ] + $arr->[ int($cnt / 2) ] ) / 2);
} else {
return $arr->[ int(($cnt - 1 ) / 2) ];
};
@@ -201,7 +202,7 @@ sub percentile($$) {
my $num = scalar @$lats;
my $i;
- for (my $i=0; $i < $num; $i++) {
+ for ($i=0; $i < $num; $i++) {
last if $lat < $lats->[$i];
}
return ($num - $i) / $num;
@@ -242,7 +243,7 @@ sub calculate($$) {
my $latency_median = median (\@latency_total);
my @latency_median_day;
for ( 0 .. $STATS_DAYS - 1 ) {
- @{$latency_day[$_]} = sort { $a <=> $b } $latency_day[$_];
+ @{$latency_day[$_]} = defined $latency_day[$_] ? (sort { $a <=> $b } @{$latency_day[$_]}) : ();
$latency_median_day[$_] = median ( $latency_day[$_] );
}
@@ -265,7 +266,7 @@ sub calculate($$) {
return {
avr_latency => $latency_median,
avr_reliability => $received_total,
- latency_day => \@latency_day,
+ latency_day => \@latency_median_day,
reliability_day => \@received_day
};
};