contiki/tools/powertrace/parse-node-power

62 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl
$max_seq = 0;
for($i = 0; $i < 1000; $i++) {
$max_radio[$i] = 0;
$min_radio[$i] = 10000;
}
while(<>) {
if(/P (\d+)\.\d+ (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/) {
$node = $1;
$seq = $2;
$all_cpu = $3;
$all_lpm = $4;
$all_tx = $5;
$all_rx = $6;
$all_idle_tx = $7;
$all_idle_rx = $8;
$cpu = $9;
$lpm = $10;
$tx = $11;
$rx = $12;
$idle_tx = $13;
$idle_rx = $14;
$nodes{$node} = 1;
$radio_now = $tx + $rx;
$idle_now = $idle_tx + $idle_rx;
$cpu_now = $lpm + $cpu;
$dutycycle = $radio_now / $cpu_now;
$dutycycle_for_node[$node][$seq] = $dutycycle;
$idle_for_node[$node][$seq] = $idle_now / $cpu_now;
if($seq > $max_seq) {
$max_seq = $seq;
}
}
}
foreach $j (keys %nodes) {
$avg = 0;
for($i = 0; $i < $max_seq; $i++) {
$avg += $dutycycle_for_node[$j][$i];
}
$idle_avg = 0;
for($i = 0; $i < $max_seq; $i++) {
$idle_avg += $idle_for_node[$j][$i];
}
print $avg / $max_seq . " " . $idle_avg / $max_seq . " $j\n";
$total_avg += $avg;
$total_idle += $idle_avg;
}
print "\n";
print STDERR "Idle percentage " . $total_idle / $total_avg . "\n";
#print STDERR "Mean duty cycle " . 100 * $mean / $num_mean . "\n";