]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
fwp-timing: Final version and a simple gnuplot script
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 11 Nov 2009 15:41:34 +0000 (16:41 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 11 Nov 2009 15:41:34 +0000 (16:41 +0100)
fwp/tests/timing/fwp-timing.c
fwp/tests/timing/fwp-timing.gnuplot [new file with mode: 0644]
fwp/tests/timing/fwp-timing.pl

index 941a8f3b003b7d8aa0e619b05a880a4e533681df..953ac1f86ab4624e38ac2790601e63733ca8bb70 100644 (file)
@@ -444,11 +444,11 @@ void *sender(void *arg)
 
 void print_stat(bool final)
 {
-       printf("Sent: %5d  Received: %5d  Lost: %5d Max: %6.3f ms",
+       printf("Sent: %5d  Received: %5d  Lost: %5d Max: %8.3f ms",
               stats.sent, stats.received, stats.lost, hist.max/1000.0);
        if (final) {
-               printf("  Max: %6.3f ms  90%%: %6.3f ms\n",
-                      hist_get_percentile(&hist, 100)/1000.0,
+               printf("  Packetloss: %7.3f %%  90%%: %8.3f ms\n",
+                      100.0*stats.lost/stats.sent,
                       hist_get_percentile(&hist, 90)/1000.0);
        }
        else
@@ -511,9 +511,8 @@ int main(int argc, char *argv[])
                goto destroy;
        }
 
-       for (i=0; i<num; i++) {
+       for (i=0; i<num; i++)
                pthread_create(&p[i]->thread, NULL, sender, p[i]);
-       }
 
        while (!exit_flag && !opt_quiet) {
                int v;
@@ -524,10 +523,10 @@ int main(int argc, char *argv[])
                usleep(100000);
        }
 
+       for (i=0; i<num; i++)
+               pthread_join(p[i]->thread, NULL);
 destroy:
        for (i=0; i<num; i++) {
-               if (!negotiation_failure)
-                       pthread_join(p[i]->thread, NULL);
                frsh_contract_cancel(p[i]->vres);
                free(p[i]);
        }
@@ -535,5 +534,5 @@ destroy:
        stats.lost = stats.sent - stats.received;
        print_stat(true);
        
-       return 0;
+       return negotiation_failure ? 1 : 0;
 }
diff --git a/fwp/tests/timing/fwp-timing.gnuplot b/fwp/tests/timing/fwp-timing.gnuplot
new file mode 100644 (file)
index 0000000..721a050
--- /dev/null
@@ -0,0 +1,11 @@
+set xlabel "Number of simultaneous streams"
+set ylabel "Time [ms]
+set yrange [0:]
+set y2range [0:100]
+set y2label "Packet loss [%]
+set y2tics
+set grid
+
+plot "./fwp-timing.dat" using 1:2 title "Maximal delay [ms]" with lp,\
+     "./fwp-timing.dat" using 1:4 title "90% [ms]" with lp,\
+     "./fwp-timing.dat" using 1:3 title "Packet loss [%]" with lp axis x1y2
index 36afde5d5fa5bc5cb010bbc8b7f8a8b623102fae..2232f5305a649a629421aa7e56c4a7488ad23e46 100755 (executable)
@@ -29,7 +29,7 @@ $SIG{TERM} = \&catch_zap;
 
 $max=10;
 $max=$ARGV[0] if (scalar(@ARGV));
-
+my @results=();
 for($i=1; $i<=$max; $i++) {
     $|++;                      # Autoflush
     printf "%3d: ", $i;
@@ -40,9 +40,23 @@ for($i=1; $i<=$max; $i++) {
        my $n = ($i-1) / @srcdst + ((($j % @srcdst) <= (($i-1) % @srcdst))  ? 1 : 0);
        $streams[$j] = $srcdst[$j]." -n $n" if ($n);
     }
-    $cmd="$omk_rules_dir/_compiled/bin-tests/fwp-timing -l 2 -q -c 10 ".join(" -/ ", @streams);
+    $cmd="$omk_rules_dir/_compiled/bin-tests/fwp-timing -l 2 -q -c 1000 ".join(" -/ ", @streams);
     #print "$cmd\n";
     $out=`$cmd`;
     print $out;
+    my @result;
+    if ($? == 0) {
+       @result = $out =~ /Max: *([0-9.]+).*Packetloss: *([0-9.]+).*90%: *([0-9.]+)/;
+    } else {
+       @result = ();
+    }
+    $results[$i] = \@result;
 }
 
+# Print data for gnuplot
+open(DAT, ">", "fwp-timing.dat");
+for($i=1; $i<=$max; $i++) {
+    my $line = "$i ".join(" ", @{$results[$i]})."\n";
+    print DAT $line;
+}
+close DAT;