# Modeling the Power Consumption of Function-Level Code Relocation for Low-Power Embedded Systems
## 4 Code Profiling Using the Source Code Insertion Technique
### Result of Code Profiling  
Based on 1,000,000 instructions, the number of instructions was increased 10 times and 100 times to perform code profiling, and at the same time, the power measurement step was carried out. Table 3 presents the results of code profiling, and indicates the mean power measured for each instruction group. Figure 5: Code relocation scheme using assembly code injection technique. \begin{table}
\begin{tabular}{c c c c} \hline \hline _Instruction Group_ & _Position of the Function_ & _Number of Instruction_ & _Power Consumption (mW)_ \\ \hline \multirow{4}{*}{DP} & \multirow{4}{*}{Flash} & x & 2.997 \\  & & 10x & 3.006 \\  & & 100x & 3.012 \\ \cline{2-4}  & & x & 2.651 \\  & & 10x & 2.656 \\  & & 100x & 2.658 \\ \hline \multirow{4}{*}{BC} & \multirow{4}{*}{Flash} & x & 2.999 \\  & & 10x & 3.007 \\ \cline{1-1}  & & 100x & 3.010 \\ \cline{1-1} \cline{2-4}  & & x & 2.659 \\ \cline{1-1}  & & 10x & 2.661 \\ \cline{1-1} \cline{2-4}  & & 100x & 2.663 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Power consumption based on code profiling result. In the case of RLS, because the memory segment to be accessed differs according to the type of data to be transferred, additional classification is possible. For example, read-only data marked with the \"const\" keyword is typically declared in flash memory. Furthermore, static and global data reside in the data segment of the SRAM, and local data and parameters reside in the stack segment of the SRAM. Additionally, the apparent effect of memory access was determined by conducting a total of five experiments on different types of data. These experiments were performed to infer the effect of memory access, i.e., by instructions in the RLS group, according to the data types mentioned above, and the results are shown in Figure 6. \begin{table}
\begin{tabular}{c c c c} \hline \hline _Instruction Group_ & _Position of the Function_ & _Number of Instruction_ & _Power Consumption (mW)_ \\ \hline \multirow{4}{*}{**DP**} & \multirow{2}{*}{Flash} & x & 2.997 \\  & & 10x & 3.006 \\  & & 100x & 3.012 \\ \cline{2-4}  & \multirow{2}{*}{SRAM} & x & 2.651 \\  & & 10x & 2.656 \\  & & 100x & 2.658 \\ \hline \multirow{4}{*}{**BC**} & \multirow{2}{*}{Flash} & x & 2.999 \\  & & 100x & 3.007 \\  & & 100x & 3.010 \\ \cline{2-4}  & \multirow{2}{*}{SRAM} & x & 2.659 \\  & & 100x & 2.651 \\ \hline \multirow{4}{*}{read Flash} & \multirow{2}{*}{Flash} & x & 3.364 \\  & & 10x & 3.378 \\  & & 100x & 3.382 \\ \cline{2-4}  & \multirow{2}{*}{SRAM} & x & 3.068 \\  & & 100x & 3.077 \\  & & 100x & 3.080 \\ \hline \multirow{4}{*}{**RLS**} & \multirow{2}{*}{Flash} & x & 3.184 \\  & & 10x & 3.228 \\ \cline{2-4}  & \multirow{2}{*}{read SRAM} & & 100x & 3.236 \\ \cline{2-4}  & & & 100x & 2.772 \\ \cline{2-4}  & \multirow{2}{*}{SRAM} & x & 2.772 \\  & & 100x & 2.777 \\ \hline \multirow{4}{*}{store SRAM} & \multirow{2}{*}{Flash} & x & 3.232 \\  & & 100x & 3.445 \\ \cline{1-1} \cline{2-4}  & \multirow{2}{*}{SRAM} & x & 2.771 \\ \cline{1-1}  & & 10x & 2.953 \\ \cline{1-1} \cline{2-4}  & & 100x & 2.994 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: _Cont._  
Figure 6: Additional classification of RLS group. As the number of instructions increased, the power consumption tended to increase. In addition, regardless of function-level code relocation, the target function consumed the most power if it consisted of an instruction of the RLS group, and consumed the least power if it consisted of an instruction of the DP group. Moreover, when the function-level code relocation, i.e., the target function, is located in the SRAM, consistently less power was consumed regardless of the type of instruction group. However, the extent to which power reduction occurs, i.e., the Power Reduction Efficiency (PRE), is different for each instruction group, as shown in Figure 7.  
The PRE due to function relocation was the highest for the RLS group of instructions by as much as 12.623%.