wishartz has asked for the wisdom of the Perl Monks concerning the following question:
seconds No of files 30: 72 60: 93 90: 75 120: 26 150: 18 180: 10 210: 5 240: 2 270: 1 300: 1 330: 2 360: 1 390: 1 450: 1 840: 1 And for the size of files, it's goes up in 25000000 kilobytes Size of file No of files 25000000: 48 50000000: 59 75000000: 30 100000000: 21 125000000: 69 150000000: 13 175000000: 4 200000000: 3 250000000: 1 350000000: 6 425000000: 13 450000000: 3 550000000: 2 675000000: 1 1075000000: 1
$bin_stage = 30; #bin size in number of seconds $bin_filesize = 25000000; #bin size in kb open(READMAP, "$command |") || error_exit("Cannot run readmap, $!"); +#run the readmap command while(<READMAP>) { #loop through the output of the readmap command if (/StageTime/){ @fields = split/\s+/; + #Split the output by white space chop $fields[9]; + # Remove the period after the last digit $diskxStats[$i]{'filesize'}=$fields[2]; $diskxStats[$i]{'ftptime'}=$fields[5]; $diskxStats[$i]{'stagetime'}=$fields[9]; if ( $fields[5] != 0 ){ $diskxStats[$i]{'transferRate'} = $fields[2] / $fields[5]; } else{ $diskxStats[$i]{'transferRate'} = $fields[2]; } if ( $fields[9] != 0 ){ $diskxStats[$i]{'stagerate'} = $fields[2] / $fields[9]; } else{ $diskxStats[$i]{'stagerate'} = $fields[2]; } $i++; } } my $j; ## Build the hash for frequency of stagetime########################## +############################## my $countstage = 0; for ( $countstage = $bin_stage; $countstage <= 3600; $countstage+=$bi +n_stage){ $nextbin = $countstage + $bin_stage; for $i ( 0 .. $#diskxStats ) { if ( $diskxStats[$i]{'stagetime'} >=$countstage && $diskxStats +[$i]{'stagetime'} < $nextbin){ $frequency_stage{$countstage}{'stage_counter'}++; } } } ##Build the hash for frequency of filesizes########################### +############################### my $file_counter= 0; my $countfile = 0; $nextbin = 0; my $array_index = 0; for ( $countfile = $bin_filesize; $countfile <= 1125000000; $countfil +e+=$bin_filesize){ $nextbin = $countfile + $bin_filesize; for $array_index ( 0 .. $#diskxStats ) { if ( $diskxStats[$array_index]{'filesize'} >=$countfile && $di +skxStats[$array_index]{'filesize'} < $nextbin){ $frequency_files{$countfile}{'filesize'}++; } } } my $stage_counter=0; my @sorted_stage = sort { $frequency_stage{$a} cmp $frequency_stage{$b +} } keys %frequency_stage; foreach $i (@sorted_stage) { print "$i: "; foreach $stage_counter ( keys %{ $frequency_stage{$i} } ) { print "$frequency_stage{$i}{$stage_counter}\n"; } } my @sorted_filesizes = sort { $frequency_files{$a} cmp $frequency_file +s{$b} } keys %frequency_files; foreach $i (@sorted_filesizes) { print "$i: "; foreach $file_counter ( keys %{ $frequency_files{$i} } ) { print "$frequency_files{$i}{$file_counter}\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Working out frequency statistics with perl
by moritz (Cardinal) on Jul 15, 2008 at 14:27 UTC | |
|
Re: Working out frequency statistics with perl
by pc88mxer (Vicar) on Jul 15, 2008 at 14:24 UTC | |
|
Re: Working out frequency statistics with perl
by hilitai (Monk) on Jul 15, 2008 at 15:22 UTC | |
|
Re: Working out frequency statistics with perl
by jethro (Monsignor) on Jul 15, 2008 at 14:50 UTC | |
|
Re: Working out frequency statistics with perl
by graff (Chancellor) on Jul 16, 2008 at 01:10 UTC | |
by wishartz (Beadle) on Jul 16, 2008 at 10:43 UTC | |
by moritz (Cardinal) on Jul 16, 2008 at 11:10 UTC | |
by wishartz (Beadle) on Jul 16, 2008 at 12:48 UTC | |
by jethro (Monsignor) on Jul 16, 2008 at 14:26 UTC |