skip to main content
10.1145/3624309.3624312acmotherconferencesArticle/Chapter ViewAbstractPublication PagessblpConference Proceedingsconference-collections
research-article
Distinguished Paper

Analyzing the Time x Energy Relation in C++ Solutions Mined from a Programming Contest Site

Published:02 November 2023Publication History

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 will consume less energy, thus optimizing a program for speed would also improve its energy efficiency.

We investigate this tendency in a set of C++ solutions mined from CSES (Code Submission Evaluation System), a popular programming competition site. Each CSES problem has several test cases, where a test case consists of a given input and its corresponding output. In order to be considered correct, the C++ solution of a user for a given problem must give for each of its test cases, under a given time limit, the expected answer. 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 30 C++ solutions, trying to select the faster and the slower ones, as also some randomly chosen solutions. Then, we evaluated the time and energy efficiency of each solution in 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, where the faster programs consume less energy. Moreover, by using the least square method, we were able to predict with good precision the energy consumption of a program based on its execution time. A manual analysis of the programs with unexpected energy consumption revealed that often their memory usage is different when compared to programs with similar execution times.

Besides helping to confirm that faster programs usually are more energy-efficient than slower ones, our results seem to indicate that our approach to predict the energy consumption of a program can help to automatically identify programs with abnormal energy consumption. Finally, our test framework, which comprises the benchmark with 450 C++ programs, the analysis script and the test results, is publicly available.

References

  1. Dirk Beyer and Philipp Wendler. 2020. CPU Energy Meter: A tool for energy-aware algorithms engineering. In Tools and Algorithms for the Construction and Analysis of Systems: 26th International Conference, TACAS 2020, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2020, Dublin, Ireland, April 25–30, 2020, Proceedings, Part II 26. Springer, 126–133.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Richard Burden and J. Douglas Faires. 2016. Análise numérica (3ª edição ed.). Cengage Learning.Google ScholarGoogle Scholar
  3. Marco Couto, Rui Pereira, Francisco Ribeiro, Rui Rua, and João Saraiva. 2017. Towards a Green Ranking for Programming Languages. In Proceedings of the 21st Brazilian Symposium on Programming Languages (Fortaleza, CE, Brazil) (SBLP ’17). Association for Computing Machinery, New York, NY, USA, Article 7, 8 pages. https://doi.org/10.1145/3125374.3125382Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Erol Gelenbe and Yves Caseau. 2015. The Impact of Information Technology on Energy Consumption and Carbon Emissions. Ubiquity 2015, June, Article 1 (jun 2015), 15 pages. https://doi.org/10.1145/2755977Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Marcus Hähnel, Björn Döbel, Marcus Völp, and Hermann Härtig. 2012. Measuring energy consumption for short code paths using RAPL. ACM SIGMETRICS Performance Evaluation Review 40, 3 (2012), 13–17.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Barbara Illowsky and Susan Dean. 2023. Book: Introductory Statistics (OpenStax). https://stats.libretexts.org/Bookshelves/Introductory_Statistics/Book%3A_Introductory_Statistics_(OpenStax)Google ScholarGoogle Scholar
  7. Jaimie Kelley, Christopher Stewart, Devesh Tiwari, and Saurabh Gupta. 2016. Adaptive power profiling for many-core HPC architectures. In 2016 IEEE International Conference on Autonomic Computing (ICAC). IEEE, 179–188.Google ScholarGoogle ScholarCross RefCross Ref
  8. Kashif Nizam Khan, Mikael Hirki, Tapio Niemi, Jukka K. Nurminen, and Zhonghong Ou. 2018. RAPL in Action: Experiences in Using RAPL for Power Measurements. 3, 2 (2018), 1–26. https://doi.org/10.1145/3177754Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Antti Laaksonen. 2020. Guide to competitive programming. Springer.Google ScholarGoogle Scholar
  10. Charalampos Marantos, Lazaros Papadopoulos, Christos P Lamprakos, Konstantinos Salapas, and Dimitrios Soudris. 2022. Bringing Energy Efficiency closer to Application Developers: An Extensible Software Analysis Framework. IEEE Transactions on Sustainable Computing (2022).Google ScholarGoogle Scholar
  11. Gayle Laakmann McDowell. 2015. Cracking the coding interview: 189 programming questions and solutions. CareerCup, LLC.Google ScholarGoogle Scholar
  12. John Mongan, Noah Suojanen Kindler, and Eric Giguère. 2012. Programming interviews exposed: secrets to landing your next job. John Wiley & Sons.Google ScholarGoogle Scholar
  13. Jerome L. Myers and A. (Arnold) Well. [n. d.]. Research design and statistical analysis. Mahwah, N.J. : Lawrence Erlbaum Associates. http://archive.org/details/researchdesignst00jero_935Google ScholarGoogle Scholar
  14. Adel Noureddine. 2022. PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools. In 2022 18th International Conference on Intelligent Environments (IE). 1–4. https://doi.org/10.1109/IE54923.2022.9826760Google ScholarGoogle ScholarCross RefCross Ref
  15. Rui Pereira, Marco Couto, Francisco Ribeiro, Rui Rua, Jácome Cunha, João Paulo Fernandes, and João Saraiva. 2017. Energy Efficiency across Programming Languages: How Do Energy, Time, and Memory Relate?. In Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering (Vancouver, BC, Canada) (SLE 2017). Association for Computing Machinery, New York, NY, USA, 256–267. https://doi.org/10.1145/3136014.3136031Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Rui Pereira, Marco Couto, Francisco Ribeiro, Rui Rua, Jácome Cunha, João Paulo Fernandes, and João Saraiva. 2021. Ranking programming languages by energy efficiency. Science of Computer Programming 205 (2021), 102609.Google ScholarGoogle ScholarCross RefCross Ref
  17. Gustavo Pinto, Anthony Canino, Fernando Castor, Guoqing Xu, and Yu David Liu. 2017. Understanding and overcoming parallelism bottlenecks in ForkJoin applications. In 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE). 765–775. https://doi.org/10.1109/ASE.2017.8115687Google ScholarGoogle ScholarCross RefCross Ref
  18. Gustavo Pinto and Fernando Castor. 2017. Energy Efficiency: A New Concern for Application Software Developers. Commun. ACM 60, 12 (nov 2017), 68–75. https://doi.org/10.1145/3154384Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Gustavo Pinto, Fernando Castor, and Yu David Liu. 2014. Understanding Energy Behaviors of Thread Management Constructs. SIGPLAN Not. 49, 10 (oct 2014), 345–360. https://doi.org/10.1145/2714064.2660235Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. John S. Seng and Dean M. Tullsen. 2003. The Effect of Compiler Optimizations on Pentium 4 Power Consumption. In Proceedings of the Seventh Workshop on Interaction between Compilers and Computer Architectures(INTERACT ’03). IEEE Computer Society, USA, 51.Google ScholarGoogle Scholar
  21. Steven S Skiena. 2008. The algorithm design manual (2 ed.). Springer.Google ScholarGoogle Scholar
  22. Vincent M Weaver, Matt Johnson, Kiran Kasichayanula, James Ralph, Piotr Luszczek, Dan Terpstra, and Shirley Moore. 2012. Measuring energy and power with PAPI. In 2012 41st international conference on parallel processing workshops. IEEE, 262–268.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Matt N Williams, Carlos Alberto Gómez Grajales, and Dason Kurkiewicz. 2013. Assumptions of multiple regression: Correcting two misconceptions. Practical Assessment, Research, and Evaluation 18, 1 (2013), 11.Google ScholarGoogle Scholar
  24. Tomofumi Yuki and Sanjay Rajopadhye. 2014. Folklore Confirmed: Compiling for Speed Compiling for Energy. In Languages and Compilers for Parallel Computing: 26th International Workshop, LCPC 2013, San Jose, CA, USA, September 25–27, 2013. Revised Selected Papers. Springer, 169–184.Google ScholarGoogle Scholar

Index Terms

  1. Analyzing the Time x Energy Relation in C++ Solutions Mined from a Programming Contest Site

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Other conferences
        SBLP '23: Proceedings of the XXVII Brazilian Symposium on Programming Languages
        September 2023
        110 pages
        ISBN:9798400716287
        DOI:10.1145/3624309

        Copyright © 2023 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 2 November 2023

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
        • Research
        • Refereed limited

        Acceptance Rates

        Overall Acceptance Rate22of50submissions,44%
      • Article Metrics

        • Downloads (Last 12 months)25
        • Downloads (Last 6 weeks)3

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      HTML Format

      View this article in HTML Format .

      View HTML Format