Code Smarter Not Harder: Measuring Energy Efficiency of LLM-Generated Code

dc.contributor.advisorAnwar, Hina, juhendaja
dc.contributor.authorSüleymanova, Fidan
dc.contributor.otherTartu Ülikool. Loodus- ja täppisteaduste valdkondet
dc.contributor.otherTartu Ülikool. Arvutiteaduse instituutet
dc.date.accessioned2025-10-23T09:36:38Z
dc.date.available2025-10-23T09:36:38Z
dc.date.issued2025
dc.description.abstractAs large language models (LLMs) become more integrated into software development, questions arise not only about correctness but also about the energy behavior of the code they generate. This thesis investigates how LLM-generated code compares to human-written solutions in terms of runtime and energy efficiency, and if minimal prompting can improve the energy profile of the output. Using four real-world programming tasks which is implemented in Python, JavaScript, and Rust, we benchmarked code produced by three LLMs, GPT-4o, LLaMA-3.3-Instruct, and Qwen 2.5-Coder against curated human-written submissions. Energy and runtime were measured using low-level CPU profiling tools in a tightly controlled environment. Results show that LLMs can often approach the performance of human-written code, but rarely exceeds it, with GPT-4o delivering the most consistent outcomes. Prompting for energy efficiency had a measurable but inconsistent effect, improving results in some cases while degrading them in others. Statistical analysis found no significant group-level differences between LLM-generated code and human-written code, but small task-level variations were also observed. These findings highlight both the potential and the current limits of prompt-based energy optimization and they provide a reproducible framework for future research in energy-aware code generation.
dc.description.abstract Kuna suured keelemudelid (LLM-id) muutuvad tarkvaraarenduses üha enam integreerituks, kerkivad esile küsimused mitte ainult loodud koodi korrektsuse, vaid ka selle energiatõhususe kohta. Käesolev lõputöö uurib, kuidas LLM-ide poolt genereeritud kood võrreldes inimeste kirjutatud lahendustega käitub täitmisaja ja energiatarbimise osas, ning kas minimaalne juhendamine (promptimine) võib parandada väljundi energiaprofiili. Kasutades nelja reaalse maailma programmeerimisülesannet, mis on implementeeritud Pythonis, JavaScriptis ja Rustis, võrdlesime kolme LLM-i - GPT-4o, LLaMA-3.3-Instruct ja Qwen 2.5-Coder - poolt genereeritud koodi valitud inimeste kirjutatud lahendustega. Energiatarbimist ja täitmisaega mõõdeti madala taseme protsessori profileerimise tööriistade abil kontrollitud keskkonnas. Tulemused näitavad, et LLM-id suudavad sageli läheneda inimeste kirjutatud koodi jõudlusele, kuid harva ületavad seda; kõige järjepidevamaid tulemusi andis GPT-4o. Energiatõhususele suunatud juhendamine avaldas mõõdetavat, kuid ebaühtlast mõju - mõnel juhul paranesid tulemused, teistel juhtudel halvenesid. Statistiline analüüs ei näidanud olulisi erinevusi LLM-ide ja inimeste loodud koodi vahel grupi tasandil, kuid ülesande tasandil ilmnesid väikesed erinevused. Tulemused toovad esile nii promptimise potentsiaali kui ka praegused piirangud energiatõhusa koodi genereerimisel ning pakuvad reprodutseeritavat raamistikku edasiseks uurimistööks selles valdkonnas.
dc.identifier.urihttps://hdl.handle.net/10062/117041
dc.language.isoen
dc.publisherTartu Ülikoolet
dc.rightsAttribution-NonCommercial-NoDerivatives 4.0 International
dc.rights.urihttps://creativecommons.org/licenses/by-nc-nd/4.0/
dc.subjectEnergy Efficiency
dc.subjectEmpirical Software Engineering
dc.subjectLarge Language Models (LLMs)
dc.subjectSustainable Computing
dc.subjectGreen Software
dc.subjectRuntime Performance
dc.subjectPrompt Engineering
dc.subjectHuman vs Machine Code
dc.subjectCode Generation
dc.subjectenergiatõhusus
dc.subjectsuured keelemudelid (LLM-id)
dc.subjectroheline tarkvara
dc.subjectempiiriline tarkvaratehnika
dc.subject.othermagistritöödet
dc.subject.otherinformaatikaet
dc.subject.otherinfotehnoloogiaet
dc.subject.otherinformaticsen
dc.subject.otherinfotechnologyen
dc.titleCode Smarter Not Harder: Measuring Energy Efficiency of LLM-Generated Code
dc.title.alternativeKoodi targemini, mitte raskemini: LLM-idega genereeritud koodi energiatõhususe mõõtmine
dc.typeThesisen

Failid

Originaal pakett

Nüüd näidatakse 1 - 1 1
Laen...
Pisipilt
Nimi:
suleymanova_softwareengineering_2025.pdf
Suurus:
1.93 MB
Formaat:
Adobe Portable Document Format