[Paper Review] EffiBench: Benchmarking the Efficiency of Automatically Generated Code
This paper introduces EffiBench, a benchmark of 1,000 efficiency-critical coding problems from LeetCode, each paired with a human-written canonical solution. It evaluates 21 large language models on code efficiency using execution time and memory usage metrics, finding GPT-4-turbo generates the most efficient code—1.69x slower on average than canonical solutions, but significantly better than other models.
Code generation models have increasingly become integral to aiding software development. Although current research has thoroughly examined the correctness of the code produced by code generation models, a vital aspect that plays a pivotal role in green computing and sustainability efforts has often been neglected. This paper presents EffiBench, a benchmark with 1,000 efficiency-critical coding problems to assess the efficiency of code generated by code generation models. EffiBench contains a diverse set of LeetCode coding problems. Each problem is paired with an executable human-written canonical solution, which obtains the SOTA efficiency on the LeetCode solution leaderboard. With EffiBench, we empirically examine the ability of 42 large language models (35 open-source and 7 closed-source) to generate efficient code. Our evaluation results demonstrate that the efficiency of the code generated by LLMs is generally worse than the efficiency of human-written canonical solutions. For example, GPT-4 generated code has an average extbf{3.12} times execution time that of the human-written canonical solutions. In the most extreme cases, the execution time and total memory usage of GPT-4 generated code are extbf{13.89} and extbf{43.92} times that of the canonical solutions. The source code of EffiBench is released on https://github.com/huangd1999/EffiBench. We also provide the LeaderBoard at https://huggingface.co/spaces/EffiBench/effibench-leaderboard.
Motivation & Objective
- Address the lack of benchmarks focused on code efficiency in existing code generation evaluation frameworks.
- Identify the gap in current benchmarks that prioritize correctness over performance metrics like execution time and memory usage.
- Provide a standardized, automated evaluation framework to measure the practical efficiency of code generated by LLMs.
- Enable systematic comparison of efficiency across diverse large language models, including open-source and closed-source models.
- Highlight the performance gap between LLM-generated code and human-optimized solutions in real-world computational workloads.
Proposed method
- Select 1,000 efficiency-critical coding problems from LeetCode, ensuring they require optimal time and space complexity.
- Pair each problem with an executable, human-written canonical solution that achieves the highest efficiency rating on LeetCode.
- Measure execution time (ET), normalized execution time (NET), maximum memory usage (MU), normalized maximum memory usage (NMU), total memory usage (TMU), and normalized total memory usage (NTMU) across multiple runs.
- Use automated execution and profiling to collect performance metrics, avoiding reliance on theoretical complexity analysis.
- Normalize performance metrics relative to the canonical solution to enable cross-model comparison.
- Evaluate 21 large language models (13 open-source, 8 closed-source) on the same benchmark using consistent input prompts and execution environments.

Experimental results
Research questions
- RQ1How do different large language models perform in generating efficient code compared to human-optimized solutions?
- RQ2To what extent does the efficiency of LLM-generated code correlate with theoretical time and space complexity?
- RQ3Which model generates the most efficient code in terms of execution time and memory usage across a diverse set of efficiency-critical problems?
- RQ4How consistent are the performance metrics of LLM-generated code across multiple runs, and what is the variability in execution time and memory usage?
- RQ5Can automated, runtime-based metrics provide a more accurate and objective evaluation of code efficiency than theoretical complexity annotations?
Key findings
- GPT-4-turbo generates the most efficient code among all evaluated models, with an average normalized execution time (NET) of 1.69x that of the canonical solution.
- The worst-case execution time of GPT-4-turbo-generated code is 45.49x slower than the canonical solution, indicating significant variability in performance across edge cases.
- GPT-3.5-turbo-1106 achieves the highest pass@1 rate (53.1%) among the models, but its NET (2.91) is still substantially worse than GPT-4-turbo’s 1.69.
- Palm-2-chat-bison and Gemini-pro generate code with significantly higher memory usage (91.90 MB and 71.95 MB, respectively), with NMU values of 3.35 and 2.72, indicating poor memory efficiency.
- Claude-instant-1 and GPT-4 show high variability in execution time, with standard deviations of 0.01s and 0.01s respectively, but still underperform in NET (3.80 and 2.27).
- The canonical solutions consistently outperform all LLM-generated code, with GPT-4-turbo achieving the closest performance—only 1.69x slower on average, indicating a persistent gap in real-world efficiency.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.