Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Bridging Functional Correctness and Runtime Efficiency Gaps in LLM-Based Code Translation

About

While large language models (LLMs) have greatly advanced the functional correctness of automated code translation systems, the runtime efficiency of translated programs has received comparatively little attention. With the waning of Moore's law, runtime efficiency has become increasingly important for program quality, alongside functional correctness. Our preliminary study reveals that LLM-translated programs often run slower than human-written ones, and this issue cannot be remedied through prompt engineering alone. Therefore, our work proposes SwiftTrans, a code translation framework comprising two key stages: (1) Multi-Perspective Exploration, where MpTranslator leverages parallel in-context learning (ICL) to generate diverse translation candidates; and (2) Difference-Aware Selection, where DiffSelector identifies the optimal candidate by explicitly comparing differences between translations. We further introduce Hierarchical Guidance for MpTranslator and Ordinal Guidance for DiffSelector, enabling LLMs to better adapt to these two core components. To support the evaluation of runtime efficiency in translated programs, we extend existing benchmarks, CodeNet and F2SBench, and introduce a new benchmark, SwiftBench. Experimental results across all three benchmarks show that SwiftTrans achieves consistent improvements in both correctness and runtime efficiency.

Longhui Zhang, Jiahao Wang, Chenhao Hu, Bingyu Liang, Jing Li, Min Zhang• 2026

Related benchmarks

TaskDatasetResultRank
Code TranslationCodeNet
Computational Accuracy (C)93.6
11
Code TranslationF2SBench
Computational Accuracy (C)91.2
11
Code TranslationSWIFTBENCH
Accuracy (C)93.1
11
Code TranslationSWIFTBENCH C-to-Python
Functional Correctness (%)90.2
6
Class-level Code TranslationClassEval-T
Functional Correctness28.4
4
Code TranslationSWIFTBENCH
Memory Usage (MB)23.9
4
Repository-level Code TranslationRepoTrans
Functional Correctness7.3
4
Repository-level Code TranslationAlphaTrans
Functional Correctness27.5
4
Showing 8 of 8 rows

Other info

Follow for update