Evaluating LLM Coding Ability: Performance, Cost, and Long-Task Efficiency

    Public benchmarks provide a useful upper bound, but they do not capture how coding models behave in large repositories, tool-heavy workflows, and long-running tasks. This article breaks coding evaluation into correctness, tool-call stability, progress efficiency, resource consumption, and behavioral control; explains how to measure effective cost and time; and outlines a reproducible test process for comparing models.

    1. A Single Score Cannot Represent Coding Ability

    Public leaderboards usually measure pass rates on fixed prompts, which can reflect a model’s upper bound on standardized tasks. Engineering teams face a different problem: the codebase is large, context is spread across multiple files, and requirements are often ambiguous. The model must first read a large amount of code before deciding where to make changes. In this setting, performance depends not only on whether the model can write correct code, but also on whether it can keep a task moving forward, call tools correctly, and control resource consumption.

    Evaluation should therefore split coding ability into separately observable metrics. The more specific the metrics are, the less likely judgment will be swayed by the impression from a single success or failure.

    2. Breaking Down Evaluation Dimensions

    At least the following five dimensions should be covered:

    1. Task correctness: one-pass task success rate, post-edit test pass rate, and number of regression failures introduced.
    2. Tool-call stability: parameter format error rate, number of failures caused by mismatched parameter names, and ability to recover after a rejected call.
    3. Progress efficiency: number of steps and actual elapsed time required to complete the same task.
    4. Resource consumption: input, output, and cache-hit token counts, as well as cost per task.
    5. Behavioral controllability: whether the model follows call constraints and adjusts its approach when it encounters limits, rather than bypassing limits with minor changes.

    Tool-Call Failures and Bypass-Style Retries

    In practice, a common phenomenon appears: when the client forbids exactly identical repeated calls, the model changes only one parameter each time, for example by shifting the read position line by line. Such calls remain valid, and the client can hardly determine from “different parameters” alone that the model is in a loop.

    This shows that loop detection cannot rely only on comparing whether parameters are exactly identical. It should judge semantic progress, for example whether the same file region is read repeatedly without producing new information. Below is an illustrative detection approach:

    1. def is_stalled(history, window=8, min_new_info=1):
    2. recent = history[-window:]
    3. # Aggregate read regions in 50-line buckets
    4. regions = {(h.path, h.start // 50) for h in recent}
    5. new_facts = sum(1 for h in recent if h.produced_new_info)
    6. return len(regions) <= 2 and new_facts < min_new_info

    In addition, fuzzy parameter-name matching and JSON repair are agent-layer capabilities that can mask underlying model format errors. During evaluation, first-call failures, successful automatic repairs, and manual interventions should be recorded separately so that repair ability is not mistakenly counted as model ability.

    3. Long Runtime and Token Use Are Not Advantages by Themselves

    Long runtime and high token consumption do not by themselves indicate high work quality. Time and tokens are inputs; validated results are outputs. Two metrics can be used to measure efficiency:

    • Effective cost per task = total cost ÷ number of tasks that pass acceptance
    • Effective time per task = total elapsed time ÷ number of tasks that pass acceptance

    If two models eventually complete the same batch of tasks, and one takes significantly longer and consumes more tokens, then it is less efficient on that batch. Extra investment is valuable only when it solves problems that the other model cannot solve. Evaluation should therefore record both quality and cost, rather than looking at only one of them.

    4. How Billing Structure Affects Actual Cost

    Actual cost is determined by two factors: unit price and consumption rate. Pay-as-you-go billing prices directly by token. Package-based billing provides a quota, and the actual consumption rate depends on task type and the model’s output habits. The two cannot be compared directly; the quota must first be converted into an equivalent cost.

    Different providers also price input, output, cache-hit, and inference-process tokens differently. Output tokens often have a higher unit price, while cache hits can significantly reduce input cost. Calculations should use the following formula to unify the basis:

    Single-task cost = (input tokens × input unit price + output tokens × output unit price + cache tokens × cache unit price) ÷ number of passed tasks

    Prices and billing rules may change at any time. Each time results are recorded, the test date and model version should also be noted to support later re-testing and comparison.

    5. Building a Reproducible Test Process

    1. Sample real tasks: select defect fixes, small feature additions, local refactors, and test additions from actual codebases, with a fixed number of tasks for each category.
    2. Fix the environment: use the same repository snapshot, tool set, system prompt, and timeout for each run.
    3. Repeat runs: run each model on each task at least three times, and record pass rate and variance.
    4. Unified scoring: check test results, code review conclusions, and whether there are unrelated changes or deleted tests.
    5. Preserve raw logs: separate records of format errors, repeated calls, and manual interventions to help locate the problem stage.

    An illustrative evaluation framework is shown below:

    1. results = []
    2. for task in tasks:
    3. for run in range(3):
    4. workspace = fresh_workspace(task.repo_snapshot)
    5. log = agent.run(task.prompt, tools=TOOLS, timeout=task.timeout)
    6. results.append({
    7. "task": task.id,
    8. "passed": run_tests(workspace, task.test_cmd),
    9. "steps": log.step_count,
    10. "elapsed": log.elapsed,
    11. "usage": log.usage,
    12. "tool_errors": log.tool_error_count,
    13. })
    14. summarize(results)

    6. Common Pitfalls in Interpreting Results

    • Using a single demo instead of statistics: one success only shows that the capability exists; it does not show that it is stable.
    • Treating “it runs” as “it is correct”: check whether unrelated files were modified, and whether tests were weakened or deleted.
    • Looking only at unit price: ignoring the total consumption required to complete a task; a low-unit-price model may need more rounds.
    • Ignoring time sensitivity: model versions and billing rules change, so conclusions should note the test date.

    7. Selection Recommendations

    • Choose by task type: code completion and simple edits focus more on latency and cost; cross-file refactors and long-chain tasks focus more on accuracy and recovery ability.
    • Build a routing strategy: low-risk tasks should first use lower-cost models, and escalate to a stronger model after failure.
    • Re-test regularly: after each model or billing rule update, re-evaluate with the same task set before deciding whether to adjust model selection.