Ensure the code is written efficiently

By Mateusz, 4 September, 2024

Ensure the code is written efficiently

  • Remove any ‘dead’ code. 

    Deciding the best programming language on its own will not make any to minimal impact on the energy efficiency when the code written itself has unnecessary lines of code slowing it down. The reduction made by this improvement might vary, depending on the scale and type of project.

  • E.g. code’s memory access patterns are cache-friendly. 

    According to (GeeksforGeeks, 2023) cache memory is significantly faster than regular memory because it is located directly in the CPU. The benefit of cache friendly code is that it significantly reduces the amount of the memory access required, therefore reducing power consumption and energy efficiency. There could also be caching introduced on the application level, which would lead to reducing unnecessary running the same code which would give the same result. Therefore, saving both time and computational power, leading to lower energy usage. Lastly, it could be implemented on the servers in huge data centres, where it could save a lot more energy due to the amount of hardware they are running. For example, where running SQL queries to request data, the more often it is used the more it will benefit the energy savings.

 

References

GeeksforGeeks (2023) Computer Organization | Locality and Cache friendly code. GeeksforGeeks. Available at: https://www.geeksforgeeks.org/computer-organization-locality-and-cache-friendly-code/.  (Accessed on: 27th August 2024)