Evaluating AI Coding Ability: Pass Rate, Latency, and Cost

    This article explains how to evaluate AI coding capability scientifically. It covers why coding ability needs separate evaluation from general Q&A, defines core metrics including task pass rate, completion rate, latency, and cost, and shows how to combine them into a composite score. It also discusses evaluation requirements for long-horizon tasks, reproducibility standards, how to interpret version-over-version improvements, how teams can build their own evaluation pipelines, and key considerations when selecting models.

    1. Why Coding Ability Needs Separate Evaluation

    General question-answering capability is not equivalent to code generation capability. Whether code actually works depends on syntax, dependency versions, runtime environment, interface definitions, and business logic all being correct at the same time. Fluency of generated text alone cannot tell you whether the output is usable. For this reason, the industry commonly adopts task-level evaluation: given a clear requirement and an initial project, the system is asked to modify code, and automated tests then determine whether the task is complete.

    Mobile app development is a typical scenario. UI state and lifecycle management are relatively complex, system interfaces change frequently across versions, and developers must also handle permissions, networking, local storage, and performance. In such scenarios, evaluation sets need to cover a wide range of problems found in real projects. Using only simple algorithm problems cannot reflect practical capability.

    2. Core Metrics and Their Meanings

    1. Task Pass Rate

    Pass rate refers to the proportion of all evaluation tasks that ultimately pass every acceptance test. The formula is: pass rate = number of passed tasks / total number of tasks. It is intuitive and easy to understand, but it is a binary judgment and cannot capture cases where the system is “almost correct.”

    2. Task Completion Rate

    Completion rate measures the degree of partial correctness, such as the proportion of acceptance cases passed or the coverage of key functional points. Completion rate and pass rate should be considered together. If completion rate is high but pass rate is low, it usually means the system completed most of the work but made mistakes in edge cases or final steps.

    3. Latency per Run

    Latency refers to the time taken for one complete task from start to finish. Two measurement scopes need to be distinguished: cumulative model inference time, and end-to-end time including tool calls, compilation, and testing. When comparing different systems, the scope must be consistent; otherwise the results are not comparable.

    4. Cost per Run

    Cost typically consists of three parts: input and output metering during inference, fees generated by tool calls, and additional overhead from retries after failures. Cost metrics should be converted to “cost per passed task.” A solution with very low per-run cost but an extremely low pass rate may not be more efficient in practice.

    3. How Metrics Work Together

    A single metric can easily mislead. Metrics need to be used in combination. The example code below demonstrates the aggregation logic; the input data is for demonstration only:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class RunRecord:
    4. passed: bool # whether all acceptance cases passed
    5. completion: float # completion rate, from 0 to 1
    6. duration_min: float # end-to-end duration in minutes
    7. cost: float # cost per run, in units consistent with the budget
    8. def summarize(records: list[RunRecord]) -> dict:
    9. n = len(records)
    10. if n == 0:
    11. raise ValueError("Evaluation records are empty")
    12. passed = [r for r in records if r.passed]
    13. pass_rate = len(passed) / n
    14. avg_completion = sum(r.completion for r in records) / n
    15. avg_duration = sum(r.duration_min for r in records) / n
    16. total_cost = sum(r.cost for r in records)
    17. # Average cost per passed task, combining quality and cost into one metric
    18. cost_per_pass = total_cost / len(passed) if passed else float("inf")
    19. return {
    20. "pass_rate": round(pass_rate, 4),
    21. "avg_completion": round(avg_completion, 4),
    22. "avg_duration_min": round(avg_duration, 2),
    23. "cost_per_pass": round(cost_per_pass, 2),
    24. }

    Among these, cost_per_pass is the key metric. It reflects both quality and cost: a solution with a low pass rate will have its unit cost inflated because the total is spread over fewer successful tasks, so it will not be overestimated merely because its per-run cost is low.

    4. Key Evaluation Points for Long-Horizon Tasks

    Long-horizon tasks are tasks that require multi-step planning, repeated modification, and self-correction to complete. When evaluating such tasks, consider the following aspects:

    • Intermediate state recording: Save each step’s code changes, test results, and error messages so that failure causes can be reviewed afterward.
    • Error recovery capability: Track whether the system can accurately locate the problem and complete a fix after a test failure.
    • Context management: How the system compresses and retains key information when task information exceeds context capacity. This directly affects success rates on long tasks.
    • Number of human interventions: Every situation requiring human intervention should be counted. If this item is ignored, the degree of automation will be overestimated.

    5. Ensuring Reproducible Evaluation Results

    Evaluation results can only be used for decision-making if they are reproducible. The following four points are basic requirements:

    1. Fixed environment: Lock dependency versions, system images, and test device configurations. Environment changes directly affect test results.
    2. Run multiple times and report statistics: Run the same task multiple times and report the mean and variation range, avoiding treating an accidental success as stable capability.
    3. Isolate evaluation data: Evaluation tasks must not appear in prompt tuning or training materials; otherwise results will be inflated by overfitting.
    4. Publish the evaluation protocol: Clearly define task sources, acceptance criteria, timeout limits, and retry rules.

    Version comparisons must be conducted on the same evaluation set and under the same protocol. Otherwise, numbers from different runs are not comparable.

    6. Interpreting Version Iteration Data

    When a new version of the same system improves its pass rate, the reasons may include improved reasoning strategies, more stable tool calls, better retry mechanisms, or targeted optimization for a certain type of task. Readers need to determine whether the improvement is general. It is advisable to check the following three points:

    • Whether the improvement is concentrated in a few task types or covers all types of tasks;
    • Whether the cost reduction is accompanied by a quality decline;
    • Whether the latency reduction comes from skipping verification steps such as compilation, testing, or code review.

    Only after all three points are confirmed can the improvement between versions be regarded as genuine progress.

    7. Building an In-House Evaluation Process Within a Team

    Most teams cannot directly apply public leaderboards, because the distribution of public tasks may not match their own business. An in-house process can be built through the following steps:

    1. Collect real requirements: Extract tasks from historical tickets and defect records, covering feature development, bug fixing, refactoring, and test writing.
    2. Write acceptance tests: Equip each task with automated test cases, avoiding reliance solely on subjective human judgment.
    3. Set metric weights: Assign weights to pass rate, cost per pass, and latency according to team priorities. For example, quality-first teams should increase the weight of pass rate.
    4. Sample manual review: Sample passed tasks to check code maintainability, security, and style consistency. Automated tests cannot cover these aspects.
    5. Update the evaluation set regularly: As the tech stack and business requirements change, replace outdated tasks and add new scenarios.

    8. Considerations for Model Selection

    • Leaderboard rankings are only a reference; applicability should be judged in combination with your own task distribution.
    • Failure cases reveal a system’s capability boundaries better than success figures. It is advisable to categorize failure types and keep records.
    • The final decision should be based on actual results from a small-scale pilot. During the pilot period, track pass rate, rework rate, and manual correction time at the same time.

    9. Conclusion

    The value of coding ability evaluation lies in turning “whether it works well” into comparable numbers. Pass rate, completion rate, latency, and cost per pass need to be used in combination and can only be compared across versions under a unified protocol. Once a team has built its own evaluation set, it can make better-informed judgments in model selection, process improvement, and effectiveness verification.