| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use strict 'refs'; |
| 4 |
use strict 'subs'; |
| 5 |
|
| 6 |
#if ($#ARGV 0) { |
| 7 |
# &usage; |
| 8 |
# exit; |
| 9 |
#} |
| 10 |
|
| 11 |
sub usage { |
| 12 |
print STDERR " usage: $0 <pattern> <time>\n"; |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
my @a = <$ARGV[0]*>; |
| 17 |
my $time = $ARGV[1]-10; |
| 18 |
|
| 19 |
foreach $file (@a) { |
| 20 |
|
| 21 |
my ($prefix, $suffix) = split(/-/,$file); |
| 22 |
my $i = $suffix*1000; |
| 23 |
|
| 24 |
# open(INPUT, "$ARGV[$file]") or die "Cannot open $ARGV[$file]: $!\n"; |
| 25 |
print STDERR "Doing $file tmp-$suffix\n"; |
| 26 |
|
| 27 |
my $command1 = "grep curr tmp-$suffix | awk \'{if (\$2==\"(0)\") {sum1+=\$11; sum2+=\$13}} END {print $i, (sum1/sum2)*100}\' >> dropRate"; |
| 28 |
|
| 29 |
# print "$command1 \n"; |
| 30 |
system($command1); |
| 31 |
|
| 32 |
my $command2 = "awk '{if (\$4 != 0) { if (\$2==50) start[\$4]=\$6; if (\$2==$time) bw[\$4]=(\$6 - start[\$4])*8/(($time-50)*1000000)}} END {for (i=1; i<=14; i++) print i, bw[i]}' $file | awk '{ if (\$1 <=2) sum1+=\$2; else if (\$1 <=4) sum2+=\$2; else if (\$1<=6) sum3+=\$2; else sum4+=\$2} END {print $i, sum1/2, sum2/2, sum3/2, sum4/8}\' >> data"; |
| 33 |
|
| 34 |
# print "$command2 \n"; |
| 35 |
system($command2); |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
|