Hi all,
I'd like to bring to your attention the following two equivalent snippet of
code:

***************   A  ********************
event void Read.readDone(error_t result, val_t val) {

        curr = val;

        if (haveHistory && (pre - curr) > 0)) {
            // do something
        }

        pre = curr;

       haveHistory = TRUE;
}
*****************************************

***************   B  ********************
event void Read.readDone(error_t result, val_t val) {

        curr = val;

        if (haveHistory && (pre - curr) > 0)) {
            // do something
        }

        pre = curr;

        if( ! haveHistory )
            haveHistory = TRUE;
}
*****************************************


Given that A and B are semantically the same and hence the "if (
! haveHistory )" in B could be removed with no effect to the correctness,
let's suppose the readDone event fires quite often; my question is:

Is A more time and energy efficient than B?

I'm pretty sure the "if ( ! haveHistory )" statement takes more CPU cycles
than the simple "haveHistory = TRUE" assignement, so A should be definitely
quicker than B;
however, what about the energy consumed?!?

Thank you,

Raffaele
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to