arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.16479cs.SE
收藏

TRACE: 评估基于LLM的代码翻译的执行效率

TRACE: Evaluating Execution Efficiency of LLM-Based Code Translation

Zhihao Gong, Zeyu Sun, Dong Huang, Qingyuan Liang, Jie M. Zhang, Dan Hao

AI总结:

本文提出TRACE基准,评估LLM翻译代码的执行效率,发现正确性不等于效率,23.5%的正确翻译存在显著低效,提示需关注效率意识。

摘要:

尽管大型语言模型(LLM)显著提升了代码翻译的功能正确性,但执行效率这一关键维度仍被忽视。我们提出了TRACE,首个专门评估LLM翻译代码效率的基准。TRACE包含1000个关键效率任务,涵盖C++、Java和Python,每个任务均配有压力测试以揭示常被小规模测试忽略的效率退化。利用TRACE,我们对28个代表性LLM进行了全面评估,揭示了几个关键发现:1)正确性不是效率的可靠代理:正确性领先者Claude-4-think仅达到中等时间效率,被较小的开源LLM如Qwen2.5-Coder-14B-Instruct超越。2)低效既普遍又具模式:23.5%的正确翻译表现出显著低效,分布在算法故障(11.9%)、语言构造不匹配(66.4%)和资源管理不当(21.7%)。3)推理时间提示策略仅带来微小改进,表明当前LLM缺乏内在效率意识。共同,我们的结果确立了效率作为代码翻译的关键维度,并将TRACE定位为面向效率评估的原理性基础。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑