RetroZilla/security/nss/lib/freebl/mpi/stats
2018-05-19 22:01:21 +08:00

40 lines
838 B
Perl

#!/usr/bin/perl
#
# Treat each line as a sequence of comma and/or space delimited
# floating point numbers, and compute basic statistics on them.
# These are written to standard output
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
$min = 1.7976931348623157E+308;
$max = 2.2250738585072014E-308;
$sum = $num = 0;
while(<>) {
chomp;
@nums = split(/[\s,]+/, $_);
next if($#nums < 0);
$num += scalar @nums;
foreach (@nums) {
$min = $_ if($_ < $min);
$max = $_ if($_ > $max);
$sum += $_;
}
}
if($num) {
$avg = $sum / $num;
} else {
$min = $max = 0;
}
printf "%d\tmin=%.2f, avg=%.2f, max=%.2f, sum=%.2f\n",
$num, $min, $avg, $max, $sum;
# end