An Evaluation of Large Language Models for Code Optimization

Code optimization has traditionally been a manual and time-consuming process in which developers identify and correct coding inefficiencies and bad programming practices. Large Language Models (LLMs) bring a fresh approach to this labour, being trained with large amounts of source code, they can detect inefficient code fragments and propose improved ones. However, concerns about their reliability, consistency across different programming languages, and trust in AI-generated solutions have slowed their adoption as automatic performance optimization tools. In this work, the code optimization capabilities of four LLMs were tested with six real-world codes written by non-expert developers, aiming to improve their execution time while maintaining correctness. A fixed methodology and identical prompts are employed, along with well-known profilers to detect bottlenecks as a starting point for every code. The results show that ChatGPT-4 Turbo significantly outperforms the other models, achieving an average runtime improvement of 31.9×, demonstrating its effectiveness in automated code optimization.

Authors

Institutions

Publication Details

Published
2025-06-16
DOI
https://doi.org/10.23919/splitech65624.2025.11091799
Primary Topic
Model-Driven Software Engineering Techniques
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

An Evaluation of Large Language Models for Code Optimization

Unai López-Novoa, Leonardo Sastoque Pinilla, Endika Tapia, Luis Norberto López-de-Lacalle
Model-Driven Software Engineering Techniques
article

An Evaluation of Large Language Models for Code Optimization

Unai López-Novoa, Leonardo Sastoque Pinilla, Endika Tapia, Luis Norberto López-de-Lacalle
article en

Abstract

Code optimization has traditionally been a manual and time-consuming process in which developers identify and correct coding inefficiencies and bad programming practices. Large Language Models (LLMs) bring a fresh approach to this labour, being trained with large amounts of source code, they can detect inefficient code fragments and propose improved ones. However, concerns about their reliability, consistency across different programming languages, and trust in AI-generated solutions have slowed their adoption as automatic performance optimization tools. In this work, the code optimization capabilities of four LLMs were tested with six real-world codes written by non-expert developers, aiming to improve their execution time while maintaining correctness. A fixed methodology and identical prompts are employed, along with well-known profilers to detect bottlenecks as a starting point for every code. The results show that ChatGPT-4 Turbo significantly outperforms the other models, achieving an average runtime improvement of 31.9×, demonstrating its effectiveness in automated code optimization.

University of the Basque Country (ES)
Openalex Percentile: Top 81%
Model-Driven Software Engineering Techniques
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.