Investigating the energy consumption of C++ and Java solutions mined from a programming contest site

IF 1.8 3区 计算机科学 Q3 COMPUTER SCIENCE, SOFTWARE ENGINEERING
Sérgio Queiroz de Medeiros, Marcelo Borges Nogueira, Gustavo Quezado
{"title":"Investigating the energy consumption of C++ and Java solutions mined from a programming contest site","authors":"Sérgio Queiroz de Medeiros,&nbsp;Marcelo Borges Nogueira,&nbsp;Gustavo Quezado","doi":"10.1016/j.cola.2025.101341","DOIUrl":null,"url":null,"abstract":"<div><div>The current concern about global warming has led to an increasing 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.</div><div>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.</div><div>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 to 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.</div><div>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. By using this approach, we could restrict, 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.</div></div>","PeriodicalId":48552,"journal":{"name":"Journal of Computer Languages","volume":"84 ","pages":"Article 101341"},"PeriodicalIF":1.8000,"publicationDate":"2025-06-16","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Computer Languages","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S2590118425000279","RegionNum":3,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0

Abstract

The current concern about global warming has led to an increasing 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 to 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. By using this approach, we could restrict, 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.
调查从编程竞赛站点挖掘的c++和Java解决方案的能耗
当前对全球变暖的关注引起了人们对计算机应用的能源效率的兴趣。假设功率是恒定的,一般趋势是更快的程序消耗更少的能量,因此优化程序的速度也会提高其能源效率。我们在一组从代码提交评估系统(Code Submission Evaluation System, CSES)中挖掘出来的c++和Java解决方案中研究了这种趋势,CSES是一个流行的编程竞赛网站,每个解决方案都必须在给定的时间限制内给出正确的答案。在这种情况下,我们可以认为一个问题的所有正确解决方案都是考虑到速度的,而不是考虑到能源效率。我们从CSES中选择了15个问题,并为每个问题挖掘了至少30个c++和Java解决方案,评估了每个解决方案在至少两台不同机器上的时间和能源效率。在我们的场景中,存在各种各样的编程风格、执行速度和内存使用,我们可以确认一个普遍趋势:更快的程序消耗更少的能量。此外,我们能够使用普通最小二乘拟合线性函数,具有良好的精度,将一个程序的能耗与它的执行时间联系起来,并自动识别异常能耗的程序。对这些程序的手工分析表明,与执行时间相似的程序相比,它们执行的分配和释放操作的数量通常不同。我们还计算了这15个CSES问题的随机c++解决方案集的能耗曲线,并尝试使用之前计算的每个CSES问题的能耗曲线将每个集与相应的CSES问题联系起来。通过使用这种方法,我们可以将每组随机c++解决方案的分类任务限制为7个CSES问题的子集,在搜索空间中减少了50%以上。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Journal of Computer Languages
Journal of Computer Languages Computer Science-Computer Networks and Communications
CiteScore
5.00
自引率
13.60%
发文量
36
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信