# Integrated Evaluation of Reliability and Power Consumption of Wireless Sensor Networks
## 6 Experimental Evaluation
### Suggestions
The possible reason for this difference may be an optimisation carried out by the processor or compiler, as the increment step is more common than the decrement one. We measured the power consumption of two similar applications in Experiment _E03_. These applications calculate the average (\(avg\)) of five numbers (_a_, \(b\), \(c\), \(d\) and _e_) in two different ways: \(sum=(a+b+c+d+e)\) and \(avg=sum/5\); and \(avg=(a+b+c+d+e)/5\). The mean power consumption of first application is 62.46% lower than the second one. By applying the hypothesis testing, it produces a \(p\)-value equal to \(1.08015\times 10^{-53}\). As the confidence level is equal to 95% and the result is less than 0.05, it means that the two applications returned different values. Hence, we concluded that is better to use the first implementation, i.e., two assignments. To understand the reason for this difference, it is important to observe that the operator '/' has a higher priority of execution than instruction '+'; and the parenthesis forced to change the priority in the execution order of the CPU instructions. When we used the parenthesis before operator '/', the CPU is forced to execute the operator '+' prior to '/'. Hence, it consumed more energy to change the priority of the execution. In Experiment _E04_, we implemented two applications that have one _if-then-else_ statement with five branches and probability of occurrence associated with each branch. Four branches have 5% probability of occurrence, and one branch has 80%. In practice, if we execute this application twenty times, there is 80% of probability of occurrence of one of the branches. The difference between these applications is the order of branches. In the first code, the branch with probability 80% is the last to be checked. While in the second one, this branch is the first one to be evaluated. The first application consumes 23.71% more energy than the second one. Similar others scenarios, we used the hypothesis testing, which returns \(3.1065\times 10^{-44}\). This value means that the second application consumes less energy than the first code. The branch that executes more times should be evaluated as soon as possible. In Experiment _E05_, we evaluated the three possibilities of incrementing a value (e.g., increment by 1) available in nesC: var++ (_Type01_), var += 1 (_Type02_) and var = var + 1 (_Type03_). We implemented an application for each of these possibilities. _Type01_ application has the lowest power consumption among the three implementations. However, as _Type02_ application has the mean very close to _Type01_, we chose to investigate if those averages are significantly different. By using the hypothesis testing, it returned a \(p\)-value equal to 0.4632, which means that the power consumption of _Type01_ and _Type02_ applications cannot be differentiated. However, _Type03_ application consumes more energy than the two others: 20.82% and 19.83% more than _Type01_ and _Type02_, respectively. Similarly to the previous experiment, we used the hypothesis testing that returned \(p\)-value equal to \(5.5745\times 10^{-20}\) and \(8.2415\times 10^{-28}\), respectively. These mean that the _Type03_ is the worst implementation when an increment is necessary. The last experiment, Experiment _E06_, evaluates a very common nesC statement: the assignment. Experiment _E06_ assesses three variations of this command: assignment of a constant, assignment of a fixed value and assignment of another variable. The power consumption of the constant and fixed value assignments are very similar, i.e., around 0.06% of the variation. As the values are very close, we used the hypothesis testing to verify whether this difference exists. The test produced a \(p\)-value equal to 0.9365, which means that these two ways returned similar values. About the variable assignment, it has the highest power consumption: 23.31% higher than constant assignment and 23.27% higher that fixed value assignment. The hypothesis testing was used to ascertain whether these differences exist.