Table of Contents
Fetching ...

Investigating the Energy Consumption of C++ and Java Solutions Mined from a Programming Contest Site

Sérgio Queiroz de Medeiros, Marcelo Borges Nogueira, Gustavo Quezado

TL;DR

The paper tackles whether energy consumption scales with execution time for C++ and Java solutions mined from the CSES programming site. It constructs 15 problems with extensive solution sets, measures time and energy on multiple machines using RAPL-based and perf-based methods, and fits a linear model $\hat{c} = a t$ after removing idle effects. The results show a strong linear relationship between time and energy, with outliers often linked to memory allocation behavior and a slope-based approach able to reduce the problem search space for classification. The work provides publicly available datasets and measurement machinery, offering practical insights for energy-aware software development and for discriminating problems via energy profiles, while outlining future work to broaden language scope and apply machine-learning-enhanced classification.

Abstract

The concern about global warming increased the interest in the energy efficiency of computer applications. Assuming power is constant, the general trend is that faster programs consume less energy, thus optimizing a program for speed would also improve its energy efficiency. We investigate this tendency in a set of C++ and Java solutions mined from Code Submission Evaluation System (CSES), a popular programming competition site, where each solution must give the correct answer under a given time limit. In such context, we can consider that all correct solutions for a problem were written with a speed concern, but not with energy efficiency in mind. We selected 15 problems from CSES and for each of them we mined at least 30 C++ and Java solutions, evaluating time and energy efficiency of each solution in at least two different machines. In our scenario, where there is a great diversity of programming styles, execution speed, and memory usage, we could confirm the general trend: faster programs consume less energy. Moreover, we were able to use ordinary least squares to fit a linear function, with good precision, that relates energy consumption of a program based on its execution time, as well as to automatically identify programs with abnormal energy consumption. A manual analysis of these programs revealed that often they perform a different amount of allocation and deallocation operations when compared to programs with similar execution times. We also calculated the energy consumption profile of sets of random C++ solutions for these 15 CSES problems, and we tried to associate each set with its corresponding CSES problem by using the energy consumption profiles previously computed for each one of them. With this approach, we restricted, for each set of random C++ solutions, the classification task to a subset of 7 CSES problems, a reduction of more than 50% in the search space.

Investigating the Energy Consumption of C++ and Java Solutions Mined from a Programming Contest Site

TL;DR

The paper tackles whether energy consumption scales with execution time for C++ and Java solutions mined from the CSES programming site. It constructs 15 problems with extensive solution sets, measures time and energy on multiple machines using RAPL-based and perf-based methods, and fits a linear model after removing idle effects. The results show a strong linear relationship between time and energy, with outliers often linked to memory allocation behavior and a slope-based approach able to reduce the problem search space for classification. The work provides publicly available datasets and measurement machinery, offering practical insights for energy-aware software development and for discriminating problems via energy profiles, while outlining future work to broaden language scope and apply machine-learning-enhanced classification.

Abstract

The concern about global warming increased the interest in the energy efficiency of computer applications. Assuming power is constant, the general trend is that faster programs consume less energy, thus optimizing a program for speed would also improve its energy efficiency. We investigate this tendency in a set of C++ and Java solutions mined from Code Submission Evaluation System (CSES), a popular programming competition site, where each solution must give the correct answer under a given time limit. In such context, we can consider that all correct solutions for a problem were written with a speed concern, but not with energy efficiency in mind. We selected 15 problems from CSES and for each of them we mined at least 30 C++ and Java solutions, evaluating time and energy efficiency of each solution in at least two different machines. In our scenario, where there is a great diversity of programming styles, execution speed, and memory usage, we could confirm the general trend: faster programs consume less energy. Moreover, we were able to use ordinary least squares to fit a linear function, with good precision, that relates energy consumption of a program based on its execution time, as well as to automatically identify programs with abnormal energy consumption. A manual analysis of these programs revealed that often they perform a different amount of allocation and deallocation operations when compared to programs with similar execution times. We also calculated the energy consumption profile of sets of random C++ solutions for these 15 CSES problems, and we tried to associate each set with its corresponding CSES problem by using the energy consumption profiles previously computed for each one of them. With this approach, we restricted, for each set of random C++ solutions, the classification task to a subset of 7 CSES problems, a reduction of more than 50% in the search space.

Paper Structure

This paper contains 16 sections, 4 equations, 9 figures, 5 tables.

Figures (9)

  • Figure 1: Description of task CSES 1640 - Sum of Two Values
  • Figure 2: Outlier detection levels for a group of solutions.
  • Figure 3: Data points and linear regression of solutions to the problem CSES 1632.
  • Figure 4: Energy Consumption Profile of Randomly Picked C++ Solutions for Problem CSES 1635. We can see many points with similar execution time and energy consumption.
  • Figure 5: Comparing the Energy Consumption Profile of Java Solutions for Problem CSES 1071 Depending on Core Availability. The measurements using perf indicate that in all machines the usage of multiple cores decreased the slope.
  • ...and 4 more figures