Debian Codegraph @

tcl/ex/red-pd/tfrc/tfrc.pl

raw
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 <pattern> <0|1> <time> <noTries>\n";
13 exit;
14 }
15
16 my $bit = $ARGV[1];
17 my $time = $ARGV[2] - 10;
18 my $tries = $ARGV[3];
19
20 my @listOfFiles = ();
21
22 for ($tryNo=1; $tryNo <= $tries; $tryNo++) {
23 my @a = <$ARGV[0]-$tryNo-*>;
24
25 foreach $file (@a) {
26
27 my ($pre1, $try, $suffix) = split(/-/,$file);
28 my $i = $suffix;
29 print STDERR "Doing $file tmp$bit-$tryNo-$suffix\n";
30
31 my $command1 = "grep curr tmp$bit-$tryNo-$suffix | awk \'{sum1+=\$11; sum2+=\$13} END {print $i, (sum1/sum2)*100}\' >> dropRate$bit-$tryNo";
32
33 # print "$command1", "\n";
34 system($command1);
35
36 my $command2 = "awk \'BEGIN {k=$i} {if (\$4!=0 && \$2==$time) if (\$4<=k/2) {if (\$4%2!=0) tfrc1+=\$6; else tcp1+=\$6} else if (\$4%2!=0) tfrc2+=\$6; else tcp2+=\$6} END {div = $time*1000000.0; print $i, tfrc1/tcp1, tfrc2/tcp2, tfrc1/div, tcp1/div, tfrc2/div, tcp2/div}\' $file >> data$bit-$tryNo";
37
38 # print "$command2", "\n";
39 system($command2);
40
41 }
42 system("sort -n +0 -1 data$bit-$tryNo -o data$bit-$tryNo");
43 system("sort -n +0 -1 dropRate$bit-$tryNo -o dropRate$bit-$tryNo");
44
45 push(@listOfFiles,"data$bit-$tryNo");
46 }
47
48 my $cmd = "awk \'{n1[\$1]+=\$2; n2[\$1]+=\$3; tf1[\$1]+=\$4; tc1[\$1]+=\$5; tf2[\$1]+=\$6; tc2[\$1]+=\$7} END {for (i=4; i<=40; i+=4) if (i in n1) print i, n1[i]/$tries, n2[i]/$tries, tf1[i]/$tries, tc1[i]/$tries, tf2[i]/$tries, tc2[i]/$tries}\' @listOfFiles > data.$bit";
49
50 #print "$cmd\n";
51 system($cmd);