Time bucket

From Federal Burro of Information
Jump to navigationJump to search

#!/usr/bin/perl

use Math::Round;

$bucket_size=100;

while ( <>) {
#       print "value: ". $_ . "\n";
        $bucket = ( round ( $_ / $bucket_size )) * $bucket_size;
#       print "bucket: ". $bucket . "\n";
        $allvalues{$bucket} = $allvalues{$bucket}+1;
        $loglines++;
};

print "# Bucket\tCount\tFrequency";

foreach $bucket (sort keys %allvalues) {
        print $bucket."\t".$allvalues{$bucket}."\t".($allvalues{$bucket}/$loglines)."\n";
}