Can you decide which programming language to use when energy efficiency is a concern? Unfortunately, no. To make things easier, a team of six researchers from three different universities in Portugal decided to investigate the performance of programming languages.
In a research paper titled “Energy Efficiency across Programming Languages,” the team presented a study of the runtime, energy consumption, and memory usage of twenty-seven well-known software languages.
Sign up for your weekly dose of what's up in emerging technology.
Over the past several years, one can sense that the strategies were created with the intention of assisting software engineers in creating faster programmes. Indeed, performance in software languages was nearly always associated with fast execution times (embedded systems were probably the single exception). However, this reality is rapidly changing in the twenty-first century, and software energy consumption is becoming a major problem for computer makers, software language engineers, programmers, and even ordinary computer users. The results for energy, time and memory are shown below.
Image: Research paper
Researchers used the Computer Language Benchmarks Game (CLBG) to compare and analyse the energy efficiency of different software programming languages. They used ten problems from the CLBG – a free software project that contains a standard collection of simple algorithmic tasks as well as a framework for executing tests for comparing performance.
Further, to measure energy consumption, the team used Intel’s Running Average Power Limit (RAPL) tool, capable of providing accurate energy estimates at a very fine-grained level with a proven history, as researchers informed. Also, the current version of RAPL allows it to be invoked from any program written in C and Java.
Is faster greener?
As per the paper, an interesting question that frequently arises in the software energy efficiency area is whether a faster program is also an energy-efficient program. The researchers point out that it isn’t as straightforward as the physics formula E (energy) = T (time) x P (power). This is partly due to the fact that power is not consumed at a steady rate, according to the researchers, who speculate that this may be influencing the work of other academics looking into how a program’s running time is related to its energy consumption. While it’s still widely assumed that faster programmes use less energy, the researchers come to a conclusion that a faster language is not always the most energy-efficient.
However, the question is hard to answer as many factors creep while measuring power consumption. This includes the quality of the compiler, libraries used, etc. However, the researchers were able to separate energy use by CPU or DRAM utilisation, determining that the CPU consumed the majority of power, about 88.94% on average, and the remaining portion was assigned to DRAM (or dynamic RAM) — regardless of whether the benchmark programme was compiled, interpreted, or executed on a virtual machine.
Additionally, while trying to figure out the possibility of a correlation between the DRAM’s energy consumption and peak memory usage, the group was surprised to note that the relationship is almost non-existent. As a result, it’s evident that DRAM energy usage has less to do with how much memory is saved at any given time and possibly more to do with how it is used.
Further to this, to compare the languages using three characteristics – energy consumption, execution time, and peak memory usage – at a time, they used a multi-objective optimisation algorithm to sort these languages, known as Pareto optimisation.
The work presented in this paper by the Portuguese researchers extends the work presented in the paper titled ”Towards a Green Ranking for Programming Languages”, where the energy consumption monitoring approach for different programming languages was introduced. In this paper, the researchers have described a study on the energy efficiency of ten different programming languages, considering a corpus of ten computing problems included in the CLBG project. They monitored the energy consumed and execution time of almost a hundred computer programs. The study concludes that C is the fastest and greenest language. However, the results also show that energy consumption is not always directly proportional to execution time. In fact, there are greener programming languages while being slower than others.