While Large Language Models (LLMs) have substantially improved the functional correctness of code translation, the critical dimension of \textit{execution efficiency} remains overlooked. We present \textbf{\textsc{trace}}, the first benchmark to explicitly assess efficiency in LLM-translated code. \textsc{trace} includes 1,000 efficiency-critical tasks across C++, Java, and Python, each augmented with stress tests that reveal efficiency degradations often overlooked by small-scale tests. Using \textsc{trace}, we conduct an extensive evaluation of 28 representative LLMs and highlight several key insights: 1) Correctness is not a reliable proxy for efficiency: the correctness leader \textit{Claude-4-think} achieves only mid-level time efficiency, outperformed by smaller open-source LLMs such as \textit{Qwen2.5-Coder-14B-Instruct}. 2) Inefficiency is both prevalent and patterned: 23.5\% of correct translations exhibit pronounced inefficiency, distributed across algorithmic faults (11.9\%), language construct mismatches (66.4\%), and resource mismanagement (21.7\%). 3) Inference-time prompt strategies bring only modest improvements, suggesting that current LLMs lack intrinsic efficiency awareness. Together, our results establish efficiency as an essential dimension of code translation and position \textsc{trace} as a principled foundation for efficiency-oriented evaluation.
TRACE: Evaluating Execution Efficiency of LLM-Based Code Translation
Key Lab of HCST (PKU), MOE(北京大学智能语言研究实验室(教育部);计算机科学与技术系);SCS, Peking University(中国科学院软件研究所);Institute of Software, Chinese Academy of Sciences(新加坡国立大学);National University of Singapore(伦敦国王学院);King’s College London(北京大学深圳研究生院电子与计算机工程学院);School of Electronic and Computer Engineering, PKU Shenzhen Graduate School
Natural Language to Code Translation with Execution
Meta AI;Toyota Technological Institute at Chicago(芝加哥丰田技术研究院);Carnegie Mellon University(卡内基梅隆大学);University of Washington(华盛顿大学)
在大型程序语料库上预训练的代码生成模型在将自然语言转换为代码方面已经显示出巨大的成功(Chen et al.,2021; Austin等人,2021年; Li等人,2022年,除其他外)。虽然这些模型没有明确地结合程序语义(即,执行结果),在培训期间,他们能够对许多问题产生正确的解决方案。然而,选择一个正确的程序从每个问题的生成集仍然具有挑战性。在这项工作中,我们引入了基于执行结果的最小贝叶斯风险解码(MBR-EXEC)的程序选择,并表明它提高了自然语言到代码任务的预训练代码模型的Few-Shot性能。我们选择输出程序从一个产生的候选人集边缘化的程序实现,共享相同的语义。由于精确等价是棘手的,我们执行每个程序上的少量测试输入近似语义等价。跨数据集,执行或模拟执行显著优于不涉及程序语义的方法。我们发现,MBR-EXEC一贯改善所有执行不知情的选择方法,这表明它是一种有效的方法,自然语言的代码翻译。我们在github.com/facebookresearch/mbr-exec上开源我们的代码,在dl.fbaipublicfiles.com/mbr-exec/mbr-exec-release.zip上开源我们的数据
CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and Generation
University of California, Santa Barbara(加利福尼亚大学圣巴巴拉分校);School of Software Engineering, Xi’an Jiaotong University(西安交通大学软件学院);Zhejiang University(浙江大学);University of Illinois at Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Alibaba Group(阿里巴巴集团);TU Wien(维也纳技术大学);University of Chinese Academy of Sciences(中国科学院大学)