## 4 Experimental Evaluation
### Application
#### 4.2.2 Result  
The first neSC application (_App1_) is showed in the following:  
```
1 implementing{
2 int8_tmean=0,a=8,b=16,c=32,d=64,e=127;
3
4 eventvoidBoot.bootootoot(
5 callTimer.startPeriodic(100);
7}
8
9 eventvoidTimer.fired(){//startmeasure
10 mean=(a+b+c+d+e)/5;
11}//endmeasure }
```  
This application would have only one assignment command (see Section 3.1.1). However, its power consumption would be equal to an application without any command. This occurs because as the variable will not used in the program (as the program has only one assignment), the compiler performs an optimization and discards this assignment in order to reduce the power consumption. Hence, the application _App1_, whose purpose is to evaluate the assignment command, also includes arithmetic operators (+ and /). Figure 13 shows the power consumption of _App1_ trough measurement and simulation. The mean difference between simulation and measurement is 0.35%. As the values are very close, we decided to  
check if those means are significantly different. By applying the hypothesis testing, it returns a p-value equal to 0.520920. Hence, we concluded that there is no sufficient evidence to reject that simulation and measurement returned different values. The second nesC application (_App2_) simply collects a temperature:  
```
1--
2 voidreadTemperature(){ //start measure
3 callTemp.read();
4}
5
6
7 eventvoidTem.readDone(error_t err, float value){
8//donothing
9}
1//end measure
10--
```  
The initial code of this application is very similar to _App1_. _App2_ invokes the command read (3) to collect a temperature and the event readDone is triggered when the reading operation terminates, _i.e._, the sensor obtained the temperature. Figure 14 illustrates that the results obtained by measurement and simulation are very similar and they have a difference around 0.19%. Additionally, we confirmed that they are similar as the hypothesis testing returns p-value equal to 0.8276. _App3_ has a function that uses three variables for aggregating data along with a selection statement (_if-then-else_):  
Figure 14: Power consumption of _App2_. Figure 13: Power consumption of _App1_. The declaration of variables and boot code (1) are similar to _App1_. The function aggregate(), as commonly found in WSN applications, makes a calculation (e.g., average) over obtained measures. The statement _if-then-else_ has associated a probability of 20% (//@0.20) because it is executes once one in five. The results obtained by simulation and measurement are illustrated in the Figure 15. The mean difference between two methods was of 23.30%. Again, we apply the hypothesis testing to them (generated p-values equal to 0.115351), which shows that there is not sufficient evidence to assert that the methods return different data. The fourth application, namely _App4_, is shown in the following:  
```
1...
2 void mean(){ //start measure
3 total=0;
4 for(i=0;i<5;i++){ //@5.0
5 total=total+value[i];
7}
8 mean=total/5; //end measure }
```  
Similarly to _App1_, this program calculates the average of five numbers, but it uses an iteration statement (_for_) to sum them (4-6). Figure 16 shows the power consumption obtained through measurement and simulation. In this case, the mean difference is around 3.09% and the hypothesis testing returned a p-value equal to 0.072628. Hence, there is no evidence that simulation and measurement values are different. Figure 15: Power consumption of _App3_.