A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llama

Vlad Andrei Cursaru, Laura Duits, Joel Milligan, Damla Ural, Berta Rodriguez Sanchez, Vincenzo Stoico*, Ivano Malavolta

*Corresponding author for this work

Research output: Chapter in Book / Report / Conference proceedingConference contributionAcademicpeer-review

Abstract

Context. Large Language Models (LLMs) are now crucial for developers to increase productivity and reduce software development time and cost. Code Llama, an LLM from Meta, is one of the most recent LLM tools. However, currently there is no objective assessment of the energy efficiency of the source code generated by Code Llama. Goal. In this paper, we present an empirical study that assesses the energy efficiency of the source code generated by Code Llama with respect to human-written source code. Method. We design an experiment involving three human-written programming problems implemented in C++, JavaScript, and Python. We ask Code Llama to generate the code of the problems using different prompts and temperatures, which sets the predictability of the output of an LLM. Therefore, we execute both implementations and profile their energy efficiency. Results. Our study shows that the energy efficiency of the code generated by Code Llama varies according to the chosen programming language and code characteristics. Human implementations tend to be more energy efficient overall, with generated JavaScript code outperforming its human counterpart. In addition, explicitly asking Code Llama to generate energy-efficient code results in an equal or worse energy efficiency, and using different temperatures does not seem to affect the energy efficiency of generated code. Conclusions. According to our results, code generated using Code Llama does not guarantee energy efficiency, even when prompted to do so. Therefore, software developers should evaluate the energy efficiency of generated code before integrating it into the software system under development.

Original languageEnglish
Title of host publicationQuality of Information and Communications Technology
Subtitle of host publication17th International Conference on the Quality of Information and Communications Technology, QUATIC 2024, Pisa, Italy, September 11–13, 2024, Proceedings
EditorsAntonia Bertolino, João Pascoal Faria, Patricia Lago, Laura Semini
PublisherSpringer Science and Business Media Deutschland GmbH
Pages161-176
Number of pages16
ISBN (Electronic)9783031702457
ISBN (Print)9783031702440
DOIs
Publication statusPublished - 2024
Event17th International Conference on the Quality of Information and Communications Technology, QUATIC 2024 - Pisa, Italy
Duration: 11 Sept 202413 Sept 2024

Publication series

NameCommunications in Computer and Information Science
Volume2178 CCIS
ISSN (Print)1865-0929
ISSN (Electronic)1865-0937
NameQUATIC: International Conference on the Quality of Information and Communications Technology
PublisherSpringer
Volume2024

Conference

Conference17th International Conference on the Quality of Information and Communications Technology, QUATIC 2024
Country/TerritoryItaly
CityPisa
Period11/09/2413/09/24

Bibliographical note

Publisher Copyright:
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024.

Funding

This project has received funding from the European COST program under the action identifier CA19135 (CERCIRAS).

FundersFunder number
European Cooperation in Science and TechnologyCA19135

    Keywords

    • Code Llama
    • Energy Consumption
    • Green Software
    • Large Language Model

    Fingerprint

    Dive into the research topics of 'A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llama'. Together they form a unique fingerprint.

    Cite this