Added the total power consumption to each powertrace printout; updated powertrace scripts to reflect this change

This commit is contained in:
adamdunkels 2010-10-06 18:40:21 +00:00
parent ad35c54473
commit 14940b65b8
3 changed files with 77 additions and 30 deletions

View File

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: powertrace.c,v 1.7 2010/09/22 22:09:52 adamdunkels Exp $ * $Id: powertrace.c,v 1.8 2010/10/06 18:40:21 adamdunkels Exp $
*/ */
/** /**
@ -53,6 +53,8 @@ struct powertrace_sniff_stats {
uint32_t input_txtime, input_rxtime; uint32_t input_txtime, input_rxtime;
uint32_t output_txtime, output_rxtime; uint32_t output_txtime, output_rxtime;
uint16_t channel; uint16_t channel;
uint32_t last_input_txtime, last_input_rxtime;
uint32_t last_output_txtime, last_output_rxtime;
}; };
#define INPUT 1 #define INPUT 1
@ -71,20 +73,30 @@ powertrace_print(char *str)
static uint32_t last_cpu, last_lpm, last_transmit, last_listen; static uint32_t last_cpu, last_lpm, last_transmit, last_listen;
static uint32_t last_idle_transmit, last_idle_listen; static uint32_t last_idle_transmit, last_idle_listen;
static uint32_t cpu, lpm, transmit, listen; uint32_t cpu, lpm, transmit, listen;
static uint32_t idle_transmit, idle_listen; uint32_t all_cpu, all_lpm, all_transmit, all_listen;
uint32_t idle_transmit, idle_listen;
uint32_t all_idle_transmit, all_idle_listen;
static uint32_t seqno; static uint32_t seqno;
uint32_t time, total_radio; uint32_t time, all_time, radio, all_radio;
struct powertrace_sniff_stats *s; struct powertrace_sniff_stats *s;
energest_flush(); energest_flush();
cpu = energest_type_time(ENERGEST_TYPE_CPU) - last_cpu; all_cpu = energest_type_time(ENERGEST_TYPE_CPU);
lpm = energest_type_time(ENERGEST_TYPE_LPM) - last_lpm; all_lpm = energest_type_time(ENERGEST_TYPE_LPM);
transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit; all_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
listen = energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen; all_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
all_idle_transmit = compower_idle_activity.transmit - last_idle_transmit;
all_idle_listen = compower_idle_activity.listen - last_idle_listen;
cpu = all_cpu - last_cpu;
lpm = all_lpm - last_lpm;
transmit = all_transmit - last_transmit;
listen = all_listen - last_listen;
idle_transmit = compower_idle_activity.transmit - last_idle_transmit; idle_transmit = compower_idle_activity.transmit - last_idle_transmit;
idle_listen = compower_idle_activity.listen - last_idle_listen; idle_listen = compower_idle_activity.listen - last_idle_listen;
@ -95,30 +107,59 @@ powertrace_print(char *str)
last_idle_listen = compower_idle_activity.listen; last_idle_listen = compower_idle_activity.listen;
last_idle_transmit = compower_idle_activity.transmit; last_idle_transmit = compower_idle_activity.transmit;
radio = transmit + listen;
time = cpu + lpm; time = cpu + lpm;
total_radio = energest_type_time(ENERGEST_TYPE_LISTEN) + all_time = all_cpu + all_lpm;
all_radio = energest_type_time(ENERGEST_TYPE_LISTEN) +
energest_type_time(ENERGEST_TYPE_TRANSMIT); energest_type_time(ENERGEST_TYPE_TRANSMIT);
printf("%s %lu P %d.%d %lu %lu %lu %lu %lu %lu %lu (radio %d.%02d%% tx %d.%02d%% listen %d.%02d%%)\n", printf("%s %lu P %d.%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu (radio %d.%02d%% / %d.%02d%% tx %d.%02d%% / %d.%02d%% listen %d.%02d%% / %d.%02d%%)\n",
str, str,
clock_time(), rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], seqno, clock_time(), rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], seqno,
all_cpu, all_lpm, all_transmit, all_listen, all_idle_transmit, all_idle_listen,
cpu, lpm, transmit, listen, idle_transmit, idle_listen, cpu, lpm, transmit, listen, idle_transmit, idle_listen,
(int)((100L * (all_transmit + all_listen)) / all_time),
(int)((10000L * (all_transmit + all_listen) / all_time) - (100L * (all_transmit + all_listen) / all_time) * 100),
(int)((100L * (transmit + listen)) / time), (int)((100L * (transmit + listen)) / time),
(int)((10000L * (transmit + listen) / time) - (100L * (transmit + listen) / time) * 100), (int)((10000L * (transmit + listen) / time) - (100L * (transmit + listen) / time) * 100),
(int)((100L * all_transmit) / all_time),
(int)((10000L * all_transmit) / all_time - (100L * all_transmit / all_time) * 100),
(int)((100L * transmit) / time), (int)((100L * transmit) / time),
(int)((10000L * transmit) / time - (100L * transmit / time) * 100), (int)((10000L * transmit) / time - (100L * transmit / time) * 100),
(int)((100L * all_listen) / all_time),
(int)((10000L * all_listen) / all_time - (100L * all_listen / all_time) * 100),
(int)((100L * listen) / time), (int)((100L * listen) / time),
(int)((10000L * listen) / time - (100L * listen / time) * 100)); (int)((10000L * listen) / time - (100L * listen / time) * 100));
for(s = list_head(stats_list); s != NULL; s = list_item_next(s)) { for(s = list_head(stats_list); s != NULL; s = list_item_next(s)) {
printf("%s %lu SP %d.%d %lu %u %lu %lu %lu %lu %lu %lu (channel %d radio %d.%02d%%)\n", printf("%s %lu SP %d.%d %lu %u %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu (channel %d radio %d.%02d%% / %d.%02d%%)\n",
str, clock_time(), rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], seqno, str, clock_time(), rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], seqno,
s->channel, s->channel,
s->num_input, s->input_txtime, s->input_rxtime, s->num_input, s->input_txtime, s->input_rxtime,
s->input_txtime - s->last_input_txtime,
s->input_rxtime - s->last_input_rxtime,
s->num_output, s->output_txtime, s->output_rxtime, s->num_output, s->output_txtime, s->output_rxtime,
s->output_txtime - s->last_output_txtime,
s->output_rxtime - s->last_output_rxtime,
s->channel, s->channel,
(int)((100L * (s->input_rxtime + s->input_txtime + s->output_rxtime + s->output_txtime)) / total_radio), (int)((100L * (s->input_rxtime + s->input_txtime + s->output_rxtime + s->output_txtime)) / all_radio),
(int)((10000L * (s->input_rxtime + s->input_txtime + s->output_rxtime + s->output_txtime)) / total_radio)); (int)((10000L * (s->input_rxtime + s->input_txtime + s->output_rxtime + s->output_txtime)) / all_radio),
(int)((100L * (s->input_rxtime + s->input_txtime +
s->output_rxtime + s->output_txtime -
(s->last_input_rxtime + s->last_input_txtime +
s->last_output_rxtime + s->last_output_txtime))) /
radio),
(int)((10000L * (s->input_rxtime + s->input_txtime +
s->output_rxtime + s->output_txtime -
(s->last_input_rxtime + s->last_input_txtime +
s->last_output_rxtime + s->last_output_txtime))) /
radio));
s->last_input_txtime = s->input_txtime;
s->last_input_rxtime = s->input_rxtime;
s->last_output_txtime = s->output_txtime;
s->last_output_rxtime = s->output_rxtime;
} }
seqno++; seqno++;
} }
@ -199,10 +240,6 @@ add_packet_stats(int input_or_output)
{ {
struct powertrace_sniff_stats *s; struct powertrace_sniff_stats *s;
if(packetbuf_attr(PACKETBUF_ATTR_CHANNEL) == 0) {
printf("Channel 0\n");
}
/* Go through the list of stats to find one that matches the channel /* Go through the list of stats to find one that matches the channel
of the packet. If we don't find one, we allocate a new one and of the packet. If we don't find one, we allocate a new one and
put it on the list. */ put it on the list. */

View File

@ -9,15 +9,21 @@ for($i = 0; $i < 1000; $i++) {
while(<>) { while(<>) {
if(/P (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/) { if(/P (\d+)\.\d+ (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/) {
$node = $1; $node = $1;
$seq = $2; $seq = $2;
$cpu = $3; $all_cpu = $3;
$lpm = $4; $all_lpm = $4;
$tx = $5; $all_tx = $5;
$rx = $6; $all_rx = $6;
$idle_tx = $7; $all_idle_tx = $7;
$idle_rx = $8; $all_idle_rx = $8;
$cpu = $9;
$lpm = $10;
$tx = $11;
$rx = $12;
$idle_tx = $13;
$idle_rx = $14;
$nodes{$node} = 1; $nodes{$node} = 1;

View File

@ -9,14 +9,18 @@ for($i = 0; $i < 1000; $i++) {
while(<>) { while(<>) {
if(/P (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/) { if(/P ([\d\.]+) (\d+) (\d+) (\d+) (\d+) (\d+) \d+ \d+ (\d+) (\d+) (\d+) (\d+)/) {
$node = $1; $node = $1;
$seq = $2; $seq = $2;
$cpu = $3; $all_cpu = $3;
$lpm = $4; $all_lpm = $4;
$tx = $5; $all_tx = $5;
$rx = $6; $all_rx = $6;
$cpu = $7;
$lpm = $8;
$tx = $9;
$rx = $10;
$nodes{$node} = 1; $nodes{$node} = 1;
$radio_now = $tx + $rx; $radio_now = $tx + $rx;