Time bucket

From Federal Burro of Information
Revision as of 16:39, 4 January 2012 by David (talk | contribs) (Created page with "<Pre> #!/usr/bin/perl use Math::Round; $bucket_size=100; while ( <>) { # print "value: ". $_ . "\n"; $bucket = ( round ( $_ / $bucket_size )) * $bucket_size; # ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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";
}