BEST: Benchmarking Efficiency in Space and Time for LLM-Generated Code
Abstract
Lay Summary
AI tools are increasingly used to write computer programs, but a program that gives the right answer is not always good. In practice, code also needs to run quickly and use as little memory as possible, especially on devices with limited resources such as phones, sensors, and embedded systems. Existing tests for AI-generated code mostly check whether the code is correct, and when they consider efficiency, they usually focus on speed rather than memory use. We introduce BEST, a new benchmark designed to test whether AI models can write code that is efficient in both running time and memory use. BEST contains 440 carefully selected programming tasks, each split into smaller subtasks with different difficulty levels and resource limits. For each subtask, experts provide strong reference solutions that reflect different trade-offs between speed and memory. We also propose a new score, dual@k, that measures how well generated code handles both kinds of efficiency. Testing 50 AI models with BEST shows that current models often struggle to produce efficient code, and they are especially weak at reducing memory use. These results can help researchers build coding AI systems that are not only correct but also more practical for real-world, resource-limited settings.