How to Evaluate Coding LLMs: Quality, Speed, and Cost

    A reliable evaluation of coding LLMs requires more than a benchmark score or a single successful interaction. This article explains how to assess defect detection, implementation quality, long-running task reliability, latency, token usage, and cost. It also outlines a reproducible evaluation process using real development tasks, consistent test conditions, structured records, and human acceptance checks.

    1. Why a Single Trial Is Not Enough

    Large language models are now part of everyday code reviews, feature development, refactoring, and test generation. Their value depends on performance across real tasks, not on a single benchmark score.

    One trial can be influenced by the task type, prompt wording, context length, or simply chance. Drawing conclusions from that experience can be misleading. Teams need to break evaluation into observable dimensions and compare models under consistent conditions.

    2. Key Evaluation Dimensions

    2.1 Defect Detection

    For code review tasks, the central question is whether a model can identify genuine defects. Three useful measures are:

    • Recall: The proportion of known defects the model finds.
    • False discovery proportion: The proportion of reported findings that are not actual defects.
    • Cross-file localization: The ability to trace defects across files.

    Implicit dependencies between modules are particularly useful for testing review capabilities. For example, a change may depend on a specific call order in a distant part of the codebase. Such a problem can be nearly invisible in a single-file review and become apparent only through repository-wide reasoning.

    Strong performance on individual files does not establish that a model can reason across an entire repository. Include dedicated cross-file cases in the evaluation.

    2.2 Implementation Quality

    Coding tasks need to answer three questions:

    1. Does the implementation meet the requirements?
    2. Does it behave as expected in the actual runtime environment?
    3. Does it follow the project’s conventions?

    Static inspection and unit tests alone are not enough. Critical execution paths need to run in practice.

    Use three acceptance levels:

    1. The code compiles.
    2. The tests pass.
    3. Runtime behavior matches expectations.

    Many defects appear only at the third level, including concurrency timing issues, configuration loading order problems, and subtle interactions with external services.

    2.3 Reliability on Long-Running Tasks

    Real coding work often involves dozens of tool calls: reading files, searching code, making changes, running tests, and revising the implementation based on errors.

    As the sequence grows, so does the context. A model may forget earlier constraints, repeat completed work, or pay less attention to details from previous steps.

    Record the relationship between context length and error rate, and check whether quality drops noticeably near the context limit. Also record the deployment configuration, including the configured context limit and whether conversation history compression is enabled.

    These settings directly affect performance. Conclusions apply only to the configuration tested.

    2.4 Latency and Throughput

    Two metrics commonly describe generation speed:

    • Time to first token: How long the user waits before output begins.
    • Output throughput: How many tokens the model generates per second.

    They affect different workloads. Long code generation is more sensitive to throughput, while interactive question answering is more sensitive to time to first token.

    However, faster output does not necessarily mean faster task completion. A model may require more iterations or produce code that needs more rework. Evaluate generation speed alongside the number of rounds needed to finish the task.

    2.5 Token Usage and Cache Hits

    Different models can consume several times as many tokens for the same task. Track three categories separately:

    • Uncached input tokens
    • Cached input tokens
    • Output tokens

    In multi-step tool workflows, accumulated context is sent again at each step, so the cache hit rate can have a substantial effect on total cost.

    Cache reuse depends on a stable prefix. Keeping system prompts, tool definitions, and the beginning of the message history unchanged makes cache hits more likely. Frequently changing that prefix—for example, by inserting a timestamp every round or reordering the history—can significantly reduce cache reuse.

    2.6 Cost Estimation

    Calculate task cost across all steps, rather than looking at a single exchange:

    • Cost per task = Σ(uncached input tokens × input price + cached input tokens × cached-input price + output tokens × output price)
    • Time per task ≈ Σ(time to first token + output tokens ÷ throughput) + tool execution time

    Use the provider’s current published prices. Promotions, subscription plans, and tiered pricing can change the comparison, so attach a date to every set of results.

    For self-hosted models, include hardware depreciation, electricity, and operational costs.

    3. Building a Reproducible Comparison

    3.1 Design the Task Set

    Choose tasks from the team’s actual work, covering code review, feature development, refactoring, and bug fixes.

    Public benchmark problems may have appeared in training data and may not reflect performance on real work. Keep part of the task set private.

    Every task should have explicit acceptance criteria and test cases. Acceptance should not depend on the evaluator’s subjective impression.

    3.2 Keep Experimental Conditions Consistent

    For each task, keep the prompt, code baseline, tool permissions, and context limit identical across models.

    Record the model version, deployment method, and sampling parameters.

    When running multiple models in parallel, give each model an independent working directory. This prevents file overwrites and stops later runs from reading artifacts produced by earlier ones.

    3.3 Cross-Check Results

    One useful approach is to have models review one another’s work:

    • Model A implements the change.
    • Model B reviews it.
    • Model C or a human performs final acceptance.

    This can reveal blind spots that a single model misses.

    Models from the same training lineage may share blind spots, so combinations of different model families can provide more useful cross-checks. Human acceptance remains essential, particularly for code involving financial transactions, permissions, or data security.

    3.4 Record and Summarize Results

    Each run should produce a structured record that can be aggregated later. The following example illustrates a record format and three basic calculations. Prices are supplied by the caller; the values in the docstring illustrate the calculation only.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class RunRecord:
    4. task_id: str
    5. model: str
    6. tests_passed: bool # Level 2 acceptance: tests pass
    7. runtime_verified: bool # Level 3 acceptance: runtime behavior is correct
    8. input_tokens: int # Total input tokens, including cached tokens
    9. cached_tokens: int # Input tokens served from cache
    10. output_tokens: int
    11. tokens_per_sec: float # Output throughput
    12. tool_time_sec: float # Tool execution time
    13. def estimate_cost(r: RunRecord, price: dict) -> float:
    14. """Prices per million tokens, e.g. {"input": 2.0, "cached": 0.2, "output": 8.0}."""
    15. uncached = r.input_tokens - r.cached_tokens
    16. total = (
    17. uncached * price["input"]
    18. + r.cached_tokens * price["cached"]
    19. + r.output_tokens * price["output"]
    20. )
    21. return total / 1_000_000
    22. def wall_time(r: RunRecord, first_token_latency: float) -> float:
    23. generation = r.output_tokens / r.tokens_per_sec if r.tokens_per_sec > 0 else 0.0
    24. return first_token_latency + generation + r.tool_time_sec
    25. def cache_hit_rate(records: list[RunRecord]) -> float:
    26. total_input = sum(r.input_tokens for r in records)
    27. total_cached = sum(r.cached_tokens for r in records)
    28. return total_cached / total_input if total_input else 0.0

    The time function is a simplified estimate for one generation step plus its associated tool execution. For multi-step tasks, accumulate the estimates across steps.

    Report pass rate, defect recall, median completion time, cost per task, and cache hit rate separately. Using the median rather than the mean for completion time reduces the influence of unusually long runs.

    4. Common Mistakes When Interpreting Results

    • Equating fewer tokens with lower cost. Token savings can be offset by additional rounds or poor cache reuse.
    • Equating generation speed with delivery efficiency. Rework and acceptance cycles determine actual delivery time.
    • Ignoring deployment settings. Results obtained with a restricted context window or history compression apply only to that configuration.
    • Drawing conclusions from too few samples. A handful of tasks can suggest a direction, but more tasks and repeated runs are needed to confirm it.
    • Looking only at pass rate. Missing a severe defect can be far more costly than reporting a false positive. Weight findings by severity.

    5. Recommendations for Model Selection and Adoption

    1. Evaluate separately by task type. Review tasks prioritize defect recall, while implementation tasks prioritize end-to-end runtime correctness. Different tasks demand different capabilities.
    2. Set a quality threshold before comparing speed and cost. A model that fails the quality requirements should not remain a candidate simply because it is inexpensive.
    3. Retest regularly. Model versions and pricing change frequently. Last quarter’s conclusions may not apply to the current version.
    4. Maintain an internal task set and evaluation scripts. Store tasks, acceptance tests, and recording scripts in a repository so they can be reused in every evaluation.
    5. Retain human acceptance checks. Model-generated reviews should support, not replace, experienced engineers’ judgment on critical code.