# BEST: Benchmarking Efficiency in Space and Time for LLM-Generated Code

Benchmark that scores LLM-written code on both time and memory

Aocheng Shen, Boyu Zhang, Jiaze Li, Ruixuan Ma, Qiankun Zhang, Jing Wang and 3 more · International Conference on Machine Learning · 2026-9-29

- **Problem** Existing benchmarks for LLM-written code measure only running time. Memory matters on embedded and IoT devices, and a time-only score cannot tell apart codes with different space complexity.
- **Method** BEST splits each task into a grid of subtasks, with one rank for time limits and one for space limits. Expert Pareto-optimal baselines anchor a weighted metric, dual@k, which scores codes on both axes together.
- **Results** Under dual efficiency, Gemini-3-Pro-Preview scored 0.849 dual@10, compared to 0.678 for DeepSeek-V3.2-Thinking.

## Why time-only benchmarks miss space

Recent benchmarks such as EffiBench, Mercury, ENAMEL, EvalPerf, COFFE and EffiBench-X measure how fast LLM-written code runs. Space gets little attention, even though it matters on memory-limited hardware such as embedded systems and IoT devices. Optimizing code often means trading time for memory, or memory for time, so a single speed score hides part of the picture.

The authors argue that these benchmarks can't tell apart codes of different space complexity.

The authors illustrate this with a range sum query that mixes point updates and range sums over one array. Three algorithms solve it: enumeration, sqrt decomposition and a Binary Indexed Tree. Moving from enumeration to the Binary Indexed Tree cuts time from O(n²) to O(n log n), but extra space rises from O(1) to O(n). A time-only benchmark would reward the fastest of the three and say nothing about its memory cost.

Building a space-aware benchmark raises three further problems: test cases, baselines and metrics. Randomly generated test cases rarely separate suboptimal algorithms, so the tests have to be built with care. A single reference implementation is also a poor baseline, because several algorithms can be optimal in different ways. Earlier metrics measure time alone, depend on hardware and can miss asymptotic differences on small inputs.

## Graded subtasks and Pareto baselines

The authors split each task into a grid of subtasks, where each rank tightens either the time limit or the space limit. For one task, the grid has n time ranks and m space ranks, giving n × m subtasks. Each row shares an input scale and a time limit, and each column shares a space limit. Higher ranks are stricter, so only codes that meet the required complexity or better pass a given cell.

In the Figure 1 example, Algorithm A passes only the first column, while Algorithm C passes only the first row.

Each subtask gets its own baseline, and that baseline is chosen to be Pareto optimal in efficiency. A code is Pareto optimal here when it can't improve time without losing space, or improve space without losing time. Experts write these baselines, because the algorithms behind efficient code are often too involved to copy from online posts.

Some tasks have one baseline that is best on both axes, so their Pareto set holds a single code.

BEST draws its tasks from LeetCode, Codeforces, AtCoder, IOI and expert-written problems, and the first version has 440 tasks. Each task passes two filters before it enters the benchmark. The first filter keeps only tasks that admit several implementations under different time and space limits. The second filter, run with GPT-5.2, Qwen3-235B-A22B and DeepSeek-V3.2, keeps tasks where at least two of the three LLMs produce codes that differ in efficiency.

## From pass@k to dual@k

Each subtask's score is a pass@k estimate, and these scores form an n × m score matrix S. The estimate uses n generated codes in total and c of them that pass the subtask, as in the formula below. \\\[ \\text{pass@}k = 1-\\binom{n-c}{k}\\Big/\\binom{n}{k} \\\] Unlike the original pass@k, a code counts as passing only when it is correct and meets the time and space limits on every test case.

A weight matrix W gives each subtask a weight through a function ω(i,j) of its two ranks. The weights must not fall as either rank rises, must grow faster with rank, and must reward codes that do well on both axes together. The authors choose \\(\\omega(i,j)=\\tau^{i-1}\\sigma^{j-1}\\), with \\(\\tau\>1\\) and \\(\\sigma\>1\\) setting how much time and space matter.

Their Theorem 4.1 says that some τ and σ satisfy all these constraints, and the proof is in an appendix. Setting τ above σ favors time, and setting τ below σ favors space.

dual@k is the Frobenius inner product of the evaluated code's score matrix with W, divided by the same inner product for the expert baseline's score matrix. \\\[ \\text{dual@}k=\\frac{\\langle S\_{\\text{eval}},W\\rangle\_F}{\\langle S\_{\\text{std}},W\\rangle\_F} \\\] Dividing by the baseline's value places each LLM relative to the expert Pareto set, not to a raw time or memory reading.

Setting σ to 0 reduces the weights to a single time column, so the time-only case is a special case of the same metric.

## What the 50-LLM evaluation shows

The authors evaluated 50 LLMs, and DeepSeek-V3.2 ran in both standard and thinking modes, giving 51 configurations. Each subtask received 20 generated codes per LLM, and open-source models were sampled at temperature 0.8. The codes were written in C++ and run on Google Cloud servers under one compiler setting with no optimization flags. The metrics use k = 1 and k = 10, with τ and σ set to 0 or 1.2 for time-only, space-only and dual efficiency.

Under dual efficiency with σ = τ = 1.2, Gemini-3-Pro-Preview scored 0.849 dual@10, compared to 0.678 for DeepSeek-V3.2-Thinking. GPT-5.2 scored 0.811 on the same setting. The authors find dual@10 below pass@10 for every LLM, which they read as correctness being pursued at the expense of efficiency.

Most LLMs scored lower on space-only dual@10 than on time-only dual@10. Llama-3.1-8B is the exception, with a time-only dual@10 of 0.244 and a space-only dual@10 of 0.248. Commercial models generally did better on space than open-source models, and Gemini-3-Pro-Preview was the highest. The authors also note that a model strong on time can be weaker on space, citing GPT-3.5-Turbo-1106 against GPT-4o-Mini as an example.

The authors link stronger results to reasoning strategies such as chain-of-thought. Large reasoning models such as Gemini-3-Pro-Preview and DeepSeek-V3.2-Thinking have higher overall dual@10 values than the other LLMs. The authors suggest step-by-step reasoning helps models avoid intuitive but inefficient implementations.

## Algorithm categories and limits of the evidence

The authors compare 10 algorithm categories for three representative LLMs: GPT-5.2, Gemini-3-Pro-Preview and DeepSeek-V3.2-Thinking. Winners differ by category, so GPT-5.2 leads on Two Pointers while Gemini-3-Pro-Preview leads on String. Graph and DP scores are relatively low for all three LLMs. The authors attribute this to efficient code that may miss corner cases in those categories.

Only C++ was used, which the authors chose because explicit memory management makes efficiency differences easier to observe. The device-independence claim holds only after the time and memory limits are recalibrated for each environment with the baselines. Because tasks may leak into training data, the authors plan to release new versions at regular intervals.

The main space and dual results use σ = τ = 1.2 or one-sided settings with 1.2, so other weight choices were not reported.

## Paper info

- **Authors**: Aocheng Shen, Boyu Zhang, Jiaze Li, Ruixuan Ma, Qiankun Zhang, Jing Wang, Bin Yuan, Shenghao Liu, Xianjun Deng
- **Venue**: International Conference on Machine Learning · Published
- **First published**: 2026-9-29
- **Added**: 2026-11-27
- **Original paper terms**: [Check in the original ↗](https://proceedings.mlr.press/v306/shen26ac.html)
- **What we show**: Paper info and commentary

[Original paper ↗](https://proceedings.mlr.press/v306/shen26ac.html)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Aocheng Shen, Boyu Zhang, Jiaze Li, Ruixuan Ma, Qiankun Zhang, Jing Wang, Bin Yuan, Shenghao Liu, Xianjun Deng (2026). BEST: Benchmarking Efficiency in Space and Time for LLM-Generated Code. International Conference on Machine Learning. https://proceedings.mlr.press/v306/shen26ac.html

**BibTeX**

```
@article{shen2026best,
  title = {{BEST: Benchmarking Efficiency in Space and Time for LLM-Generated Code}},
  author = {Aocheng Shen and Boyu Zhang and Jiaze Li and Ruixuan Ma and Qiankun Zhang and Jing Wang and Bin Yuan and Shenghao Liu and Xianjun Deng},
  year = {2026},
  journal = {International Conference on Machine Learning},
  url = {https://proceedings.mlr.press/v306/shen26ac.html}
}
```

## Other paper commentary

- [Do LLMs Signal When They’re Right? Evidence from Neuron Agreement](https://refivu.com/en/papers/bc0f460c-030c-47f4-9e74-9dd6af4c68c4-do-llms-signal-when-they-re-right-evidence.md)
- [To Believe or Not to Believe Your LLM: Iterative Prompting for Estimating Epistemic Uncertainty](https://refivu.com/en/papers/b71ecca0-59f2-4260-b74f-1c35839640b8-to-believe-or-not-to-believe-your-llm.md)
- [Evaluating Ukrainian Grammatical Competence in Language Models: Probability Versus Prompting](https://refivu.com/en/papers/b9da328b-a55a-404e-8dab-7573f504b062-evaluating-ukrainian-grammatical-competence-in-language.md)
- [Evidence-Aligned Benchmarking and Learning for Medical Video Language Models](https://refivu.com/en/papers/403144c2-124b-4deb-ae8e-ee18219c9fef-evidence-aligned-benchmarking-and-learning-for-medical-video.md)
- [CriticEval: Evaluating Large-scale Language Model as Critic](https://refivu.com/en/papers/49cb4d52-0b81-4cbd-9b74-dfe48638ac34-criticeval-evaluating-large-scale-language-model-as-critic.md)
- [How Many Sources, Not Just How Many Problems: Planning the Precision of LLM Evaluations from Earlier Results](https://refivu.com/en/papers/1af869bf-a94d-4c3d-8125-3cd015747743-how-many-sources-not-just-how-many-problems.md)
- [Language Generation in the Limit: Complexity Barriers and Implications for Learning](https://refivu.com/en/papers/b62e98e0-e2be-4547-bca1-268f6aad51d4-language-generation-in-the-limit-complexity-barriers-and.md)
- [Information-theoretic Limits of Online Classification with Noisy Labels](https://refivu.com/en/papers/26e61d3d-9795-4588-9302-67cab944aa04-information-theoretic-limits-of-online-classification-with.md)
- [Implicit Intelligence - Evaluating Agents on What Users Don’t Say](https://refivu.com/en/papers/46a3027e-e7cd-4c3e-be85-2fe588fd1675-implicit-intelligence-evaluating-agents-on-what-users-don.md)
- [Why Self-Distillation Helps and Hurts: Denoising vs. Signal Forgetting](https://refivu.com/en/papers/c70638c0-8d0a-4b89-9840-3a8ed7406fca-why-self-distillation-helps-and-hurts-denoising-vs.md)
- [Don’t Drop Dropout: Optimizing Layer Sparsity for Efficient LLM Training and Inference](https://refivu.com/en/papers/c6799446-0a64-4c27-835e-5fb01a7e9ecb-don-t-drop-dropout-optimizing-layer-sparsity-for.md)
- [ArcFace: Additive Angular Margin Loss for Deep Face Recognition](https://refivu.com/en/papers/c413067c-e2eb-43a0-8011-b952f120296a-arcface-additive-angular-margin-loss-for-deep-face.md)

## Terms in this paper

- [Frobenius inner product](https://refivu.com/en/terms/670ad217da1e-frobenius-inner-product)
- [Gemini-3-Pro-Preview](https://refivu.com/en/terms/ae166dcbc492-gemini-3-pro-preview)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/cb1e03ca-1dd5-40d9-9de5-96ad427e5bc8-best-benchmarking-efficiency-in-space-and-time-for)
