contiki/tools/powertrace/parse-node-power

56 lines
1.3 KiB
Perl
Executable File

#!/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+)/) {
$node = $1;
$seq = $2;
$cpu = $3;
$lpm = $4;
$tx = $5;
$rx = $6;
$idle_tx = $7;
$idle_rx = $8;
$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";