TRACE: Evaluating Execution Efficiency of LLM-Based Code Translation
This paper introduces **TRACE**, the first benchmark designed to evaluate the execution efficiency of LLM-translated code, revealing that functional correctness is a poor proxy for efficiency and that current models frequently produce inefficient code due to algorithmic faults, language mismatches, and resource mismanagement.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you hire a master translator to translate a complex recipe from French to English. The translator does a perfect job: the ingredients are correct, the steps make sense, and if you follow the English version, you get a delicious cake. Functionally, the translation is perfect.
But here's the catch: The French recipe said, "Stir the pot gently for 1 minute." The English translation says, "Stir the pot gently for 1 minute," but the translator accidentally added a hidden instruction: "Before you start, walk around the kitchen 10,000 times to warm up your muscles."
You still get the cake, but it takes you 10 hours instead of 10 minutes. You wasted energy, time, and money.
This is exactly the problem TRACE (the subject of this paper) is trying to solve in the world of Artificial Intelligence.
The Problem: "Correct but Slow"
For a while, we've been asking AI models (Large Language Models or LLMs) to translate code from one programming language (like C++) to another (like Python). We've been very happy if the code works. If the AI produces code that runs without crashing and gives the right answer, we give it a gold star.
But the researchers behind this paper realized: Just because it works doesn't mean it's good.
They found that AI models often translate code in a way that is functionally correct but incredibly inefficient. It's like the AI translated the recipe but forgot to remove the "walk around the kitchen" step. In the real world, this means software that runs 500 times slower or eats up 30 times more computer memory than it needs to.
The Solution: The TRACE Benchmark
To fix this, the authors created TRACE. Think of TRACE as a stress test gym for code translators.
- The Old Way: Previous tests were like a "light jog." They gave the AI simple problems (like adding two small numbers) to see if the code worked. The AI passed easily.
- The TRACE Way: TRACE is a marathon with a heavy backpack. It takes those same problems but creates "stress tests"—massive, difficult inputs that push the computer to its limits.
- Analogy: If the old test asked, "Can you lift a 5lb weight?" TRACE asks, "Can you lift a 500lb weight while running a sprint?"
- Suddenly, the AI that looked perfect on the light jog is struggling to breathe under the heavy load.
What They Discovered
The researchers put 28 different AI models through this gym. Here are the three big things they found:
1. Being "Smart" Doesn't Mean Being "Efficient"
The AI models that got the highest scores for "correctness" (the ones that got the most gold stars) were often the slowest runners.
- Analogy: The most famous, expensive translator (Claude-4-think) was great at grammar but terrible at speed. Meanwhile, a smaller, less famous open-source model (Qwen2.5) was actually much faster and more efficient.
- Lesson: A correct translation is not a guarantee of a good translation.
2. The Mistakes Follow Patterns
The researchers looked at why the code was slow. They found three main "culprits":
- The Algorithm Swap (12%): The AI changed the math entirely. Instead of using a fast shortcut, it used a slow, roundabout way to solve the problem.
- The Wrong Tool (66%): This was the most common mistake. The AI picked the wrong "tool" for the job.
- Analogy: Imagine the original code used a screwdriver (fast and precise). The AI translated it to use a hammer (it gets the job done, but it's clumsy and slow). In programming, this happens when an AI uses a slow data structure (like a tree) when a fast one (like a hash map) would have been perfect.
- The Heavy Backpack (22%): The AI added unnecessary weight. It used giant, heavy objects to do simple tasks, wasting memory.
- Analogy: Using a massive, industrial-sized truck to deliver a single letter.
3. "Prompting" Only Helps a Little
The researchers tried to fix the problem by giving the AI better instructions (like saying, "Please be efficient!").
- Analogy: It's like telling a runner, "Try to run faster!" It helps a tiny bit, but it doesn't change the fact that the runner is wearing heavy boots. The AI doesn't intrinsically understand efficiency; it just guesses.
Why This Matters
This paper is a wake-up call. For years, we've been celebrating AI code translation just because it "works." But in the real world, efficiency is everything.
If you build a website or an app using AI-translated code that is 500% slower, your users will wait forever, your servers will crash, and your electricity bill will skyrocket.
TRACE is the first tool that forces us to stop asking, "Does it work?" and start asking, "Does it work well?" It ensures that the code we generate isn't just a working recipe, but a recipe that actually gets dinner on the table in time.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.