Evaluating AI Coding Ability: Methods and Model Selection in Practice

    This article describes how to evaluate AI coding tools for real engineering work, using mobile app development as the main example. It covers common task types, four core metrics (pass rate, average completion, average time, and cost per success), a reproducible evaluation workflow, and a way to weigh quality, speed, and cost when choosing a model.

    1. Why Systematic Evaluation of AI Coding Ability Matters

    AI-assisted programming tools can already handle engineering scaffolding, UI code generation, and API call wrapping. When teams adopt these tools, a common problem is that demos look good, but real projects often require repeated rework. The reason is that demos usually use a single, clean task, while real engineering work involves multi-file changes, dependency version constraints, device compatibility, and existing business logic. The focus of evaluation should therefore shift from “can it write code” to “can it deliver runnable, verifiable results under engineering constraints.”

    2. Typical Task Types in Mobile App Development

    Mobile app development tasks generally fall into the following categories:

    • App initialization: create the project structure, configure build scripts, and integrate basic components.
    • Feature development: implement screens, state management, network requests, and local storage.
    • Code migration: replace old interfaces or deprecated patterns with their new-version equivalents.
    • Adaptation: handle differences in screen sizes, OS versions, and permission models.
    • Bug fixing: locate and modify code based on crash logs or test failure messages.

    Difficulty and risk vary considerably across these tasks. Initialization and boilerplate generation are relatively stable. Cross-module migration and permission-related changes depend more on contextual understanding and are more likely to introduce hidden defects. An evaluation task set should cover all of these types and be stratified by difficulty. Relying only on simple tasks produces overly optimistic conclusions.

    3. Core Evaluation Metrics and How to Read Them

    3.1 Pass Rate

    Pass rate is the proportion of tasks whose output passes the predefined acceptance checks: successful compilation, and all unit tests and UI tests passing. It shows directly whether a task succeeded, but it does not show the quality of that success. Acceptance criteria must be fixed in advance, including the build environment, test cases, and pass conditions. If the criteria change between batches, the results cannot be compared.

    3.2 Average Completion

    Completion measures how much of a task was finished when the task did not fully pass. For example, if a task has five acceptance criteria and the model meets four, its completion is 80%. Completion shows how close the model came to success and helps teams estimate the effort of manual fixes. High completion does not mean the remaining work is easy to fix, however. A critical defect may sit exactly in the unfinished part.

    3.3 Average Time

    Time covers the full process from when the agent receives a task to when it returns its output. This process may include multiple rounds of reasoning, tool calls, and self-verification. Time directly affects iteration speed. Teams that need fast feedback find long single-run times hard to accept. For migration tasks that run in nightly batches, longer times are acceptable. When evaluating, record both the median and the long-tail distribution, because a few extreme samples can skew the average.

    3.4 Single-Run Cost and Cost per Success

    Single-run cost is the compute and service fee for completing one full task. A more useful metric is cost per success, which is the total cost divided by the number of passed tasks:

    Cost per success = Total run cost / Number of passed tasks

    Example: Model A has a 20% pass rate and costs $10 per run, so its cost per success is $50. Model B has a 40% pass rate and costs $30 per run, so its cost per success is $75. Model B has a higher price per run, but its higher pass rate reduces rework and manual intervention. A low unit price does not mean a low total cost.

    The sample code below summarizes the key metrics for a batch of run records:

    1. def summarize(runs):
    2. total = len(runs)
    3. passed = [r for r in runs if r.passed]
    4. pass_rate = len(passed) / total
    5. avg_completion = sum(r.completion for r in runs) / total
    6. avg_hours = sum(r.hours for r in runs) / total
    7. total_cost = sum(r.cost_usd for r in runs)
    8. cost_per_success = total_cost / len(passed) if passed else float("inf")
    9. return {
    10. "pass_rate": pass_rate,
    11. "avg_completion": avg_completion,
    12. "avg_hours": avg_hours,
    13. "cost_per_success": cost_per_success,
    14. }

    4. Building a Reproducible Evaluation Workflow

    Evaluation results are useful for decisions only if they can be reproduced. We recommend the following process:

    1. Fix the task set: put the task descriptions, initial code snapshots, dependency versions, and acceptance scripts under version control.
    2. Standardize the runtime environment: use a container or the same build image to avoid variations caused by local environment differences.
    3. Standardize the agent configuration: keep the prompt templates, tool permissions, maximum number of rounds, and timeouts consistent.
    4. Run multiple times and use statistics: run each task several times and examine the distribution of results, rather than relying on a single result.
    5. Keep process logs: record the files changed, command output, and failure causes for each run, so you can analyze where the model is weak.
    6. Manually review passing results: check code readability and maintainability, and confirm that the model did not “cheat” by modifying or deleting tests.

    Sample code:

    1. for task in task_set:
    2. for attempt in range(N):
    3. env = create_isolated_env(task.base_snapshot)
    4. result = agent.run(task.prompt, env, timeout=task.timeout)
    5. verdict = run_acceptance(env, task.checks)
    6. record(task.id, attempt, result, verdict)

    5. Trade-offs in Model Selection: Quality, Speed, and Cost

    No single option is best in every case. Selection requires trade-offs among quality, speed, and cost, depending on the scenario. Each scenario also has different priorities:

    Scenario Primary Metrics Reason
    Core business module development Pass rate, completion Defects are costly, so correctness is essential
    Batch boilerplate code generation Cost per success Task volume is large, and quality requirements per run are manageable
    Urgent bug fixing Average time Fast feedback is needed to shorten downtime

    To compare several candidate options, first normalize each metric to the same range, then compute a weighted sum:

    1. def normalize(values, higher_is_better=True):
    2. lo, hi = min(values), max(values)
    3. if hi == lo:
    4. return [1.0] * len(values)
    5. scaled = [(v - lo) / (hi - lo) for v in values]
    6. return scaled if higher_is_better else [1 - s for s in scaled]

    After normalization, calculate the composite score using your team’s business weights. Each team should set its own weights based on its constraints. Do not copy another team’s configuration directly.

    6. Practical Recommendations

    • Use models in tiers: assign complex architecture decisions and cross-module changes to the most capable models, and assign repetitive boilerplate code to lower-cost, faster models.
    • Set quality gates: AI-generated code must pass compilation, static analysis, automated tests, and code review before it is merged into the main branch.
    • Limit permission scope: give agents access only to the code repositories and runtime environments the task requires. Do not expose production keys or user data.
    • Re-test regularly: model version updates change capability boundaries. Re-run a fixed evaluation set periodically and update selection conclusions accordingly.
    • Ensure data compliance: desensitize code and logs before submitting them to external services, and follow your organization’s data classification policy.