TL;DR
This paper introduces EffiBench-X, a novel multi-language benchmark designed to rigorously evaluate the efficiency of code generated by Large Language Models (LLMs). It reveals a significant gap between LLM-generated code and human expert solutions in terms of runtime and memory usage, even when the code is functionally correct, highlighting a critical area for future LLM research.
What Problem Does This Paper Address?
Current benchmarks for evaluating LLM-generated code primarily focus on functional correctness, often neglecting code efficiency. This is problematic because as LLMs are increasingly used in real-world applications, inefficient code can lead to substantial resource overhead, impacting performance and feasibility, especially in resource-constrained environments like mobile devices or latency-sensitive cloud services. Existing efficiency benchmarks also suffer from limitations such as a lack of language diversity (often focusing only on Python), data contamination (using problems LLMs might have seen during training), and limited complexity (using overly simple tasks). EffiBench-X aims to address these shortcomings by providing a comprehensive, multi-language benchmark that uses recent, complex competitive programming problems.
Methods
EffiBench-X is built around a curated collection of "efficiency-critical" programming problems sourced from competitive programming platforms. To mitigate data contamination, problems released after October 2023 were prioritized. The benchmark includes two types of problems: functional (requiring a specific function/class) and standard I/O (requiring a complete program). For each problem, canonical human-expert solutions serve as efficiency baselines. The evaluation infrastructure uses a sandboxed execution environment with high-resolution profiling to measure execution time (ET), memory peak (MP), and memory integral (MI). LLM-generated solutions are compared against these human baselines using a scoring system that clips results to the [0, 1] interval and averages them across all test cases and problems.
Datasets
The paper introduces EffiBench-X, a new benchmark comprising efficiency-critical problems from competitive programming platforms like Aizu, AtCoder, CodeChef, Codeforces, and LeetCode. To ensure novelty and reduce data contamination, problems released after October 2023 were prioritized. The benchmark supports six programming languages: Python, C++, Java, JavaScript, Ruby, and Golang.
Key Insights and Ideas
- Efficiency is a Major Bottleneck: Despite impressive functional correctness, LLMs consistently generate code that is significantly less efficient than human experts. This suggests that current LLM training and architectures are not optimized for performance.
- Language Matters: LLMs exhibit substantial performance variations across different programming languages. Dynamically-typed languages like Python, Ruby, and JavaScript tend to yield more efficient code compared to statically-typed languages like Java, C++, and Go.
- Model Size and Specialization: Larger models and specialized variants (e.g., those with reasoning capabilities) generally perform better, but there's a potential for performance degradation in smaller models when reasoning capabilities are added without careful tuning.
- Problem Type Impact: LLMs perform significantly better on functional problems than on standard I/O problems, indicating challenges with optimizing I/O operations, buffer management, and input parsing.
Key Results
The study evaluated 26 state-of-the-art LLMs. Even the best-performing LLM, Qwen3-32B, achieved only about 62% of human-level efficiency on average. DeepSeek-R1 demonstrated strong performance, achieving an average ET of 61.33% and Pass@1 of 72.79% across all languages. For instance, DeepSeek-R1's Python code was significantly more efficient than its Java code. Gemini-2.5-Pro led in correctness (Pass@1 of 79.43%) but was not the most efficient in execution time.
Limitations and Future Work
The authors acknowledge several limitations:
- Focus on Algorithmic Efficiency: The benchmark primarily evaluates algorithmic and data structure efficiency, potentially not covering all efficiency considerations critical in domains like low-level system programming or large-scale data processing.
- Lack of Granular Analysis: The current analysis quantifies the efficiency gap but doesn't deeply delve into the root causes of LLM inefficiency at a granular code level.
- Computational Demands: Extensive efficiency evaluations across multiple languages, models, and problems are computationally intensive, posing a barrier for replication.
Future work should focus on developing LLMs with enhanced optimization capabilities across diverse languages, particularly for end-to-end programming problems. Further research into understanding and addressing the specific reasons for LLM inefficiency in different programming paradigms (like standard I/O) is also crucial.
Summary updated