# Fog vs. Cloud Computing: Should I Stay or Should I Go? +
## 4 Analyzing Test Cases
### Deciding between Fog and Cloud Considering Energy Consumption  
Similarly to what we did in the previous subsection, we start by obtaining values for \(s\), \(t\), and \(f\). However, we will now use energy consumption as our cost type and evaluate our test cases on two different devices, namely a NodeMCU platform and a Raspberry Pi 3 board. For the NodeMCU, we calculate \(t\) by taking the execution time for each test case (displayed in Tables 15 and 16 in Appendix B) and multiplying it by the voltage of the device (2 V) and the electric current for when no data are being transmitted (17.2 mA) [27], resulting in the values reported in Tables 17 and 18 in Appendix B. We use the same method to calculate the values of \(s\), multiplying the time it takes to send the data to the cloud (7.3 ms for fog-prone cases and 0.1825 ms for cloud-prone cases) by the voltage and by the electric current for when data are being transmitted (70 mA) [27], producing \(s=1.022\) mJ for fog-prone cases and \(s=0.02555\) mJ for cloud-prone ones. The next step is to calculate \(C_{f0}\) and \(C_{c0}\) for \(f=1\), the worst-case scenario from the fog point of view. Given \(z=65\),536, we use Equation (5) to determine the penalty for processing a value in the fog when it would cost less to do so in the cloud (\(p\)). Tables 17 and 18 have all the values for \(p\), which are less than 0.0002 for fog-prone scenarios and less than 0.006 for cloud-prone scenarios. We again use 0.5% as the limit for the increase in cost that we are willing to pay to estimate the value of \(f\), which allows us to test over 13,000 values for most fog-prone cases (with the exception of Outlier 256, where \(v\) ranges between 3600 and 5700, as this benchmark executes a more costly procedure in comparison to the others) and over 320 values for most cloud-prone ones (here, the values of \(v\) range between 90 and 150 for Outlier 256), as can been seen in Tables 17 and 18. The last step is to estimate \(f\) and plot the resulting linear equations using the simplified versions of Equations (1) and (2) (i.e., \(C_{f}=t+s\cdot f\) and \(C_{c}=s\)), as illustrated by Figure 11. From Tables 17 and 18, we see that the slope estimate error is less than 5% in 13 out of the 20 fog-prone cases and in 16 out of the 20 cloud-prone ones, which again is a good result for only 0.5% maximum risk in the processing cost. Moreover, from the 11 remaining test cases, 10 correctly choose the more profitable approach (the case that does not choose correctly is discussed below). We see that these results are analogous to the ones obtained in Section 4.2, with the expected choice being made on most fog- and cloud-prone cases and the same four test cases appearing as exceptions (fog-prone MinMax \([-15,15]\) and MinMax \([-5,5]\) executed on HRelHumidity and cloud-prone MinMax \([-15,15]\) on HVisibility and HWindSpeed). Figure 11: Graphs of the linear equations for each dataset and benchmark using energy consumption as the cost: NodeMCU. Nonetheless, we can see one interesting difference in the cloud-prone Outlier 16 cases, as all lines are very close to \(C_{f}=C_{c}\). In this type of situation, it is necessary to check the slope values to get a more accurate view of the decisions being made. From Table 11, we have the following slope estimates (and real values): for HRelHumidity, \(-1.0070\) (\(-1.0128\)); for HVisibility, \(-0.9836\) (\(-1.0105\)); for HWBTempC, \(-1.0106\) (\(-1.0032\)); for HWindSpeed, \(-1.0019\) (\(-1.0048\)); and for Synthetic, \(-0.9990\) (\(-0.9945\)). From that, we have that fog is chosen for HRelHumidity, HWBTempC, and HWindSpeed, with the cloud being chosen for the other two datasets. However, in the case of HVisibility, the real slope value tells us that the best choice would have been processing the values on the fog. Even so, considering how close the fog cost (\(0.02529\,\mathrm{mJ}\)) is to the cloud cost (\(0.02555\,\mathrm{mJ}\)) in this case, choosing the less profitable option will not greatly affect the performance of the system.