Changeset 4745


Ignore:
Timestamp:
11/03/08 01:50:44 (8 years ago)
Author:
werner
Message:
  • don't pass around bytes and time separate, use the rate instead
  • print "*1000B" instead of ambiguous "kB"
  • compute standard deviation in new function std_dev
File:
1 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/wlan-perf/report

    r4743 r4745  
    44sub extract_ttcp() 
    55{ 
    6     local ($name, *bytes, *time, *csw) = @_; 
     6    local ($name, *rate, *csw) = @_; 
    77 
    88    open(F, $name) || die "$name: $!"; 
    99    while (<F>) { 
    1010        if (/ (\d+) bytes in (\S+) real seconds/) { 
    11             push(@bytes, $1); 
    12             push(@time, $2); 
     11            push(@rate, $1/$2); 
    1312        } 
    1413        if (/ (\d+)\+(\d+)csw/) { 
     
    3029sub ttcp_set() 
    3130{ 
    32     local (*bytes, *time, *csw, $i) = @_; 
     31    local (*rate, *csw, $i) = @_; 
    3332 
    34     $bytes += $bytes[$i]; 
    35     $time += $time[$i]; 
     33    $rate += $rate[$i]; 
    3634    $csw += $csw[$i]; 
    37     return &ttcp_format($bytes[$i]/$time[$i], $csw[$i]); 
     35    return &ttcp_format($rate[$i], $csw[$i]); 
     36} 
     37 
     38 
     39sub std_dev() 
     40{ 
     41    local ($sq_sum, $avg, $n) = @_; 
     42 
     43    return sqrt($sq_sum/$n-$avg*$avg); 
    3844} 
    3945 
     
    4248{ 
    4349    local ($label_tx, $label_rx, $tx, $rx) = @_; 
    44     local (@tx_bytes, @tx_time, @tx_csw); 
    45     local (@rx_bytes, @rx_time, @rx_csw); 
    46     local ($tx_bytes, $tx_time, $tx_csw); 
    47     local ($rx_bytes, $rx_time, $rx_csw); 
     50    local (@tx_rate, @tx_csw); 
     51    local (@rx_rate, @rx_csw); 
     52    local ($tx_rate, $tx_csw); 
     53    local ($rx_rate, $rx_csw); 
    4854    local ($gap) = " " x 4; 
    4955 
     
    5258       $label_rx, " ", "-" x (15-length $label_rx), "\n"; 
    5359    print " " x 5, 
    54       sprintf("%-8s %-7s", "kB/s", "ctx_sw"), $gap, 
    55       sprintf("%-8s %-7s", "kB/s", "ctx_sw"), "\n"; 
     60      sprintf("%-8s %-7s", "*1000B/s", "ctx_sw"), $gap, 
     61      sprintf("%-8s %-7s", "*1000B/s", "ctx_sw"), "\n"; 
    5662 
    57     &extract_ttcp($tx, *tx_bytes, *tx_time, *tx_csw); 
    58     &extract_ttcp($rx, *rx_bytes, *rx_time, *rx_csw); 
    59     for ($i = 0; $i != @tx_bytes; $i++) { 
     63    &extract_ttcp($tx, *tx_rate, *tx_csw); 
     64    &extract_ttcp($rx, *rx_rate, *rx_csw); 
     65    for ($i = 0; $i != @tx_rate; $i++) { 
    6066        print sprintf("%3d: ", $i+1), 
    61           &ttcp_set(*tx_bytes, *tx_time, *tx_csw, $i), $gap, 
    62           &ttcp_set(*rx_bytes, *rx_time, *rx_csw, $i), "\n"; 
     67          &ttcp_set(*tx_rate, *tx_csw, $i), $gap, 
     68          &ttcp_set(*rx_rate, *rx_csw, $i), "\n"; 
    6369    } 
    6470    print "AVG: ", 
    65       &ttcp_format($tx_bytes/$tx_time, $tx_csw/@tx_bytes), $gap, 
    66       &ttcp_format($rx_bytes/$rx_time, $rx_csw/@tx_bytes), "\n"; 
     71      &ttcp_format($tx_rate/@tx_rate, $tx_csw/@tx_rate), $gap, 
     72      &ttcp_format($rx_rate/@tx_rate, $rx_csw/@tx_rate), "\n"; 
    6773    print "\n"; 
    6874} 
     
    106112      sprintf("%7.2f", $avg), "/", 
    107113      sprintf("%7.2f", $max), "  ", 
    108       sprintf("%7.2f", sqrt($sq_sum/@time-$avg*$avg)), " ms\n"; 
     114      sprintf("%7.2f", &std_dev($sq_sum, $avg, $#time+1)), " ms\n"; 
    109115} 
    110116 
Note: See TracChangeset for help on using the changeset viewer.