in reply to calculating peak hour
(Untested code. Assumes that the time period covered by the dataset begins and ends with 0 open periods. Hour-to-hour transitions are left as an exercise for the reader.)my @proc_start = sort @start; my @proc_end = sort @end; my $count = 0; my $max = 0; while (@proc_start && @proc_end) { if ($proc_start[0] lt $proc_end[0]) { # Next event is a start $count++; $max = $count if $count > $max; shift @proc_start; } else { # Next event is an end $count--; shift @proc_end; } } print "Peak was $max\n";
|
|---|