diff options
Diffstat (limited to 'security/nss/lib/freebl/mpi/stats')
-rwxr-xr-x | security/nss/lib/freebl/mpi/stats | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/security/nss/lib/freebl/mpi/stats b/security/nss/lib/freebl/mpi/stats new file mode 100755 index 000000000..a5deb94c0 --- /dev/null +++ b/security/nss/lib/freebl/mpi/stats @@ -0,0 +1,39 @@ +#!/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 |