Tools for parsing and plotting a power trace from Contiki
This commit is contained in:
parent
0eae63b29a
commit
8f7e96b06f
5 changed files with 248 additions and 0 deletions
71
tools/powertrace/parse-power-data
Executable file
71
tools/powertrace/parse-power-data
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/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+)/) {
|
||||
$node = $1;
|
||||
$seq = $2;
|
||||
$cpu = $3;
|
||||
$lpm = $4;
|
||||
$tx = $5;
|
||||
$rx = $6;
|
||||
|
||||
$nodes{$node} = 1;
|
||||
|
||||
$radio_now = $tx + $rx;
|
||||
$cpu_now = $lpm + $cpu;
|
||||
$dutycycle = $radio_now / $cpu_now;
|
||||
|
||||
$dutycycle_for_node[$node][$seq] = $dutycycle;
|
||||
|
||||
# print STDERR "Node $node Seq $seq duty cycle " . ($tx + $rx)/($lpm + $cpu) . ", " . ($tx + $rx) . "/" . ($lpm + $cpu) . "\n";
|
||||
$radio[$seq] += $radio_now;
|
||||
$time[$seq] += $cpu_now;
|
||||
|
||||
if($seq >= 0) {
|
||||
$mean += $dutycycle;
|
||||
$num_mean++;
|
||||
}
|
||||
|
||||
if($dutycycle > $max_radio[$seq]) {
|
||||
$max_radio[$seq] = $dutycycle;
|
||||
}
|
||||
|
||||
if($dutycycle < $min_radio[$seq]) {
|
||||
$min_radio[$seq] = $dutycycle;
|
||||
}
|
||||
if($seq > $max_seq) {
|
||||
$max_seq = $seq;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 0; $i < $max_seq; $i++) {
|
||||
if($time[$i] != 0) {
|
||||
print "$i " . $radio[$i] / $time[$i] . " " . $min_radio[$i] . " ". $max_radio[$i] . " ";
|
||||
foreach $j (keys %nodes) {
|
||||
print $dutycycle_for_node[$j][$i] . " ";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach $j (keys %nodes) {
|
||||
$avg = 0;
|
||||
for($i = 0; $i < $max_seq; $i++) {
|
||||
$avg += $dutycycle_for_node[$j][$i];
|
||||
}
|
||||
print STDERR "Node $j avg duty cycle " . 100 * $avg / $max_seq . "\n";
|
||||
}
|
||||
|
||||
if($num_mean != 0) {
|
||||
print STDERR "Mean duty cycle " . 100 * $mean / $num_mean . "\n";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue