| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use strict 'refs'; |
| 4 |
use strict 'subs'; |
| 5 |
|
| 6 |
if ($#ARGV !=3 ) { |
| 7 |
&usage; |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
sub usage { |
| 12 |
print STDERR " usage: $0 <flowfile> <tmpfile> <time> <-|+>\n"; |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
my $time = $ARGV[2] - 10; |
| 17 |
my $sign = $ARGV[3]; |
| 18 |
|
| 19 |
my $command2 = "awk '{if (\$4 > 0 && \$4<= 11) { if (\$2==50) start[\$4]=\$6; if (\$2==$time) bw[\$4]=8*(\$6 - start[\$4])/(($time-50)*1000000)}} END {for (i=1; i<=11; i++) print (i $sign 0.125), bw[i]}' $ARGV[0] > data${sign}boxes"; |
| 20 |
|
| 21 |
system($command2); |
| 22 |
|
| 23 |
open(TMPF, "$ARGV[1]") or die "Cannot open $ARGV[1]: $!\n"; |
| 24 |
my $outfile = "data${sign}cdf"; |
| 25 |
open(OUTF, ">$outfile") or die "Cannot open $outfile: $!\n"; |
| 26 |
|
| 27 |
my $total=0; |
| 28 |
while (<TMPF>) { |
| 29 |
@line = split; |
| 30 |
if (/done-resp/ and $line[6] > 50) { |
| 31 |
$time=$line[7] - $line[6]; |
| 32 |
print OUTF "1 $time\n"; |
| 33 |
$total++; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
close(TMPF); |
| 38 |
close(OUTF); |
| 39 |
|
| 40 |
system("sort -n +1 -2 $outfile -o $outfile"); |
| 41 |
|
| 42 |
open(FILE, "$outfile") or die "Cannot open $outfile: $!\n"; |
| 43 |
open(OUTF,">$outfile.cdf") or die "Cannot open bad.cdf : $!\n"; |
| 44 |
|
| 45 |
my $frac = 0; |
| 46 |
while (<FILE>) { |
| 47 |
($f1, $f2) = split; |
| 48 |
$frac += $f1/$total; |
| 49 |
|
| 50 |
print OUTF "$f2 $frac\n"; |
| 51 |
} |
| 52 |
|
| 53 |
close(FILE); |
| 54 |
close(OUTF); |
| 55 |
|