How to Evaluate Code LLMs: A Guide to Capability Benchmarking and Cost-Effectiveness Calculation

    "Strong" is not a measurable or acceptable criterion for a code model. To decide whether a model can be integrated into a development workflow—and whether it is worth the cost—you need to turn capability into observable behavior and turn cost into spend per unit of output. This article lays out a reusable evaluation method built around a controlled experiment: six tasks run inside an agentic coding tool, fully offline, with a 30-minute limit per task (actual runtime about 43 minutes). It covers how to design tasks, fix conditions, and score results so conclusions are credible and reproducible; how to read each capability dimension; and how to compute a core metric, cost per effective output unit, by folding together token usage, human rework, and latency. Readers will find question-bank examples, a weighted scorecard, worked cost calculations, and reusable pseudocode for cost accounting.

    How to Evaluate Code LLMs: A Guide to Capability Benchmarking and Cost-Effectiveness Calculation

    1. Introduction: From “Is it good?” to “Can we use it, and is it worth it?”

    The performance of large models on coding tasks is often described as “getting better,” but “better” by itself is not a comparable or verifiable metric. The moment you need to answer “can we plug this into our development workflow?” or “which option is more cost-effective?”, you must break capability down into observable behaviors and translate cost into spend per unit of output.

    To do this, you can design a set of controlled experiments: place 6 tasks in front of an agentic coding tool, disable networking for the entire run, and cap each task at 30 minutes (actual runtime was about 43 minutes). This article uses that setup as the main thread to lay out a reusable evaluation method, focusing on two problems:

    • Capability evaluation: How to design tasks, fix the conditions, and score results so the conclusions are credible and reproducible.
    • Cost-effectiveness calculation: How to translate pass rate, token consumption, elapsed time, and human rework into “cost per effective output unit.”

    2. Evaluation Design: Fix the Conditions First, Then Compare Capability

    2.1 Test Conditions: Turning “Coincidence” into “Reproducibility”

    The results of coding tasks are heavily influenced by the environment. The same response, run in environments with different tool sets, permissions, and system prompts, can produce markedly different code. So the first step of an evaluation is to record the complete “test conditions” rather than just starting the run.

    Condition Example value Why set it this way
    Subject under test A specific code LLM (pinned to an exact version identifier) Different versions of a same-named model can perform very differently, so results must be bound to a version
    Runtime environment Agentic coding tool (agent runtime form) The tool set, permissions, and system prompt all significantly affect performance
    Execution window About 49 minutes Makes it easier to verify versions and configuration when reproducing
    Network policy Networking disabled throughout Cuts off external knowledge sources to test whether the model can answer honestly without retrieval
    Per-task time limit 30 minutes Prevents infinite loops and unbounded trial-and-error; timeouts are flagged separately
    Question bank size 6 tasks Covers different capability dimensions while keeping per-run cost controlled
    Actual total time About 43 minutes Used for latency analysis and cost-effectiveness calculation

    Three of these settings deserve a closer look:

    1. No networking. It cuts off external retrieval and also blocks any external links given in the tasks. At this point the model can only rely on its parametric knowledge and the local codebase, which is what makes the evaluation comparable. Evaluators should also verify: did the model attempt to make its own network requests, and were the links the task asked it to visit actually accessed? If a link was never accessed yet the answer happens to be “correct,” be wary that the model may be guessing from memory.
    2. Time limit. The 30-minute per-task cap turns “repeated attempts that never converge” into an explicit observable event: timeout, interruption, or incompletion. Exceeding the limit does not mean the model lacks capability, but the number of timeouts, the tokens consumed before timing out, and the number of human interventions are all important cost signals.
    3. Reproducibility. The more completely you record the conditions, the more comparable a retest will be. If your records omit generation parameters such as a random temperature and the output-length cap, the same model on the same task can still yield different results. A more robust approach is to run each task 2–3 times and describe performance with the mean or median.

    2.2 Question Bank Design: From “Self-Description” to “Real Engineering Tasks”

    Tasks should be layered by capability dimension, increasing context length and task complexity from easy to hard:

    # Capability dimension Example task Key observation point
    Q0 Meta self-description State its own model, version, and knowledge cutoff Is the source of information clear; is the boundary description honest
    Q1 Knowledge timeliness Judge whether a versioned API used by a code snippet is still supported recently Does it search, declare uncertainty, or just guess
    Q2 Instruction following & structured output Output a static-analysis result in a specified format Is the format valid; are all fields present
    Q3 Tool calling & multi-step planning Locate and fix a defect in a given codebase Are the steps reasonable; can it self-check and self-correct
    Q4 Test generation & engineering standards Complete tests for a given module and handle edge cases Are the tests effective; do they match the project’s style
    Q5 Comprehensive refactoring Refactor part of the implementation while keeping the existing interface Does it break compatibility; what is the overall quality

    The question bank follows three principles:

    • Difficulty gradient. From a low-cost identity check to a high-cost end-to-end refactor, this both locates the capability boundary and controls the cost of a single evaluation run.
    • Realistic tasks. Tasks are drawn as much as possible from the team’s real requirements and historical defects, with sensitive information removed.
    • Verifiable tasks. Every task should have a clear pass criterion, such as whether the unit tests pass or whether the output matches an agreed structure. Results must come from executable assertions, not from the subjective feeling that something “reads well.”

    2.3 Scorecard: Turning “Feeling” into a “Scale”

    The scorecard quantifies each capability dimension into fixed points, making it easy to compare across runs and track over time:

    Dimension Scoring points Suggested weight
    Answer correctness Does it solve the core problem; does the result pass tests 35%
    Knowledge honesty Does it honestly state information sources and acknowledge uncertainty 15%
    Instruction following Does it meet format, constraint, and prohibition requirements 15%
    Engineering standards Readability, error handling, consistency with existing style 15%
    Execution efficiency Number of tool-call steps, elapsed time, token consumption 10%
    Security Does it leak sensitive information or perform dangerous operations 10%

    The total score is calculated as follows:

    1. Overall score = Σ (dimension score ÷ dimension max score × suggested weight)

    Weights should be adjusted to the use case:

    • Code-completion scenarios: emphasize correctness and execution efficiency.
    • Code-review and refactoring scenarios: emphasize engineering standards and security.

    3. Reading the Capability Dimensions: What Each Task Is Really Testing

    3.1 Q0: Meta Self-Description Tests “Transparency”

    Q0 asks the model under test to state “who it is, what version, and where its knowledge ends.” It looks simple but carries a lot of information.

    For this kind of question, a model’s description of its own identity usually comes from a system prompt injected by the runtime, not from any “introspection” of its internal weights. What a model can reliably report is only: the facts the runtime told it, plus its rough sense of its training-data distribution.

    The model’s answer clearly separated three points: model and version information, the knowledge cutoff, and the source of that information. It also volunteered that “the closer an event is to the knowledge cutoff, the sparser the memory,” so events after late spring were only fragmentary impressions.

    This kind of answer has three kinds of value:

    1. It states the information source. Separating “environment declaration” from “model memory” lets the user judge how far a given answer can be trusted.
    2. It shows boundary awareness. Voluntarily exposing the decay range of its memory is effectively telling the user in advance: “please verify recent facts separately.”
    3. It provides evidence for behavioral consistency. After the evaluator ran 14 follow-up questions to cross-check, the answers remained stable, indicating that this self-awareness is not a one-off “script.”

    Q0 took about 1 minute, less than one-fortieth of the total run time. It costs very little yet provides a baseline for interpreting all the subsequent answers.

    3.2 Knowledge Timeliness: Distinguishing “Knows,” “Remembers,” and “Makes Up”

    A knowledge cutoff is easily confused with real-time knowledge. It only indicates roughly when the training data ends; it does not mean the model reliably and completely masters all information up to that point. The closer you get to the cutoff, the less sufficient the training corpus, and the thinner the model’s memory of recent events, version changes, and API evolution.

    Under no-network conditions, when facing a question that needs recent information, three behaviors can appear:

    1. Attempt to go online. This violates the evaluation constraint and counts as a compliance failure.
    2. Admit uncertainty. Stating that its knowledge may be outdated and recommending that the user check the official documentation is acceptable behavior.
    3. Give plausible-looking but actually wrong content directly. This is the most dangerous case, because it outputs unverifiable conclusions in a confident tone.

    In engineering practice, follow these principles:

    • For time-sensitive information such as version numbers, API signatures, and security advisories, prefer retrieval-augmented generation (RAG) and treat the external knowledge base as the source of truth.
    • Explicitly instruct the model in the prompt to label its information sources and confidence level.
    • For key conclusions, cross-verify with automated tests and authoritative documentation.

    3.3 Instruction Following: Parseable Output Is a Prerequisite for Automation

    In an agentic coding tool, a model’s output is often the input to a downstream step. A format error can directly break the pipeline. Common instruction-following problems include:

    • Being asked to output only a patch but getting a long explanation appended;
    • Being asked to output in a fixed structure but having fields added or removed on its own;
    • Being told not to modify certain files but adjusting unrelated code along the way.

    There are three ways to improve this:

    1. Use structured output to define fields and types.
    2. Validate the output against a schema, and directly retry or escalate to a human when it fails.
    3. In the scorecard, make “violating a prohibition” an automatic-fail item.

    4. The Execution Stage: Tool Calling, Debugging, and Comprehensive Refactoring

    4.1 Q1–Q2: Retrieval, Parsing, and Structured Output

    The task provides a code snippet that uses a versioned API and asks the model to determine whether it is still supported, based on the dependency versions pinned in the repository, and to output the conclusion in a prescribed structure. This task tests both knowledge timeliness and instruction following at once.

    The ideal behavior is:

    • First inspect the dependency declaration file to confirm the version actually in use;
    • Then check whether the project already wraps the same kind of API;
    • Finally, produce a structured conclusion of “is it usable, and on what basis.”

    The scoring focus is not “the conclusion happened to be right” but whether the conclusion has a traceable basis.

    4.2 Q3: From Error to Localization to Fix

    The debugging task provides a test case that reliably reproduces a failure and asks the model to locate the root cause and complete the fix within the time limit. What this tests is not only “can it modify code” but also “can it reproduce, localize, and verify”:

    • Reproduce: Can it reliably trigger the problem and narrow down the trigger conditions;
    • Localize: Can it distinguish symptoms from root cause rather than patching the symptom;
    • Verify: After the fix, can the original test pass without breaking other tests.

    A common typical problem is “treating the symptom, not the cause”—for example, adding null-handling to a return value without addressing the source that actually produces the null. When scoring, focus on the root-cause analysis and the regression-test results.

    4.3 Q4–Q5: Test Generation and Comprehensive Refactoring

    Test-generation tasks test edge-case thinking, such as whether it can cover empty input, oversized input, concurrent calls, and abnormal returns. Comprehensive-refactoring tasks require restructuring the implementation without breaking the external interface, testing overall command of the constraints.

    For these two categories, an “generate–execute–revise” loop is recommended:

    • After the model produces a solution, immediately compile and run the tests in an isolated environment;
    • Feed the failure messages back to the model for revision;
    • Set a maximum number of iterations to prevent infinite loops.

    One point deserves special attention: if the tests are generated by the model under test itself, you can get a situation where “the tests and the implementation are wrong together.” So scoring must bring in hidden tests prepared in advance by the evaluator.

    5. Cost-Effectiveness Calculation: From “Unit-Price Comparison” to “Cost per Effective Output Unit”

    5.1 Three Common Pitfalls

    • Looking only at unit price. A low unit price with many retries and high correction costs can end up costing more overall.
    • Looking only at accuracy. A 95%-accurate option, where every failure needs to be redone by hand, can have hidden costs that eat up most of the benefit.
    • Ignoring human rework and waiting time. A developer’s review, modification, and waiting for responses are all real costs.

    5.2 Core Metric: Cost per Effective Output Unit

    Putting “cost” together with “effective output” gives you a core metric that can be compared across options:

    1. Cost per effective output unit = Total spend ÷ Tasks passed
    2. Total spend = Model call cost + Human rework cost

    The model call cost can be estimated with the following formula (the prices are only examples; the actual billing rules of the chosen service apply):

    1. Estimated cost = input tokens ÷ 1,000,000 × input unit price
    2. + output tokens ÷ 1,000,000 × output unit price
    3. + cached-hit tokens ÷ 1,000,000 × input unit price × cache discount

    Take input and output unit prices of 3 and 15 per million tokens as an example: one task consumes 15,000 input tokens and 4,000 output tokens, with 1 failed retry, so the cost is about (15000×2×3 + 4000×2×15) ÷ 1000000 = 0.21; if human rework takes 20 minutes at a labor cost of 100 per hour, the rework cost is about 33.33.

    As you can see, in most enterprise scenarios the cost of a single call is far smaller than the cost of human rework. The focus of evaluation should shift from “saving call fees” to “reducing rework.”

    5.3 Latency Is Also a Cost

    Response time is an important part of the developer experience. Recommended metrics include: average time per task, timeout rate, and time to first token. You can convert waiting time into a cost, or directly use “effective output per unit time,” i.e., tasks passed divided by total elapsed time.

    5.4 A Reusable Cost-Accounting Tool

    The following language-agnostic pseudocode consolidates the formulas above into an accounting process:

    1. # Input: list of test-case results + billing unit prices (prices are illustrative, replace with actual)
    2. INPUT:
    3. cases: List[Case]
    4. price: {input, output} # Unit: currency per 1M tokens
    5. PROCESS:
    6. total_cost = 0
    7. total_manual_cost = 0
    8. passed = 0
    9. total_time = 0
    10. FOR EACH case IN cases:
    11. cost = input_tokens × price.input / 1000000
    12. + output_tokens × price.output / 1000000
    13. total_cost = total_cost + cost
    14. total_manual_cost = total_manual_cost + manual_rework_hours × hourly_rate
    15. total_time = total_time + elapsed_seconds
    16. IF case.passed:
    17. passed = passed + 1
    18. IF passed == 0:
    19. RETURN {conclusion: "No comparable data; expand the sample or adjust the question bank"}
    20. RETURN:
    21. pass_rate = passed / count(cases)
    22. cost_per_effective_unit = (total_cost + total_manual_cost) / passed
    23. output_per_unit_time = passed / total_time

    5.5 Applying It to This Report’s Data: Even a Small Sample Yields Conclusions

    Run a simplified accounting over the experiment above:

    • 5 of 6 tasks completed, counted as 4 passed;
    • Input and output tokens estimated at 30,000 and 10,000 per task;
    • Input and output unit prices set at 3 and 15 per million tokens;
    • Model call cost is about 0.24;
    • Labor rate set at 100 per hour, so 43 minutes is about 71.67.

    This gives:

    • Cost per effective output unit: about 17.98 per task;
    • Effective output per unit time: about 0.093 tasks per minute.

    If you instead complete it entirely by hand at 25 minutes per task, 6 tasks take 150 minutes, equal to 250, for a unit cost of about 41.67.

    It must be stressed that this is only an example to demonstrate the calculation method. Real accounting must use actual token usage, actual billing prices, and your own team’s labor cost.

    At the same time, the other side must be faced honestly: the 1 unfinished task, if handled by a human, would cost about 41.67 more; and if the model’s output also needs human review, that cost is not included here. This precisely shows that capability boundaries directly determine cost-effectiveness: the more tasks a model can complete independently, the more obvious the unit-cost advantage; the closer you get to the capability boundary, the higher the proportion of human fallback, and the more the advantage gets diluted.

    6. Optimization Practices and Common Pitfalls

    6.1 Optimization Practices for the R&D Workflow

    • Retrieval augmentation. Feed internal API docs, design specifications, and a historical defect library into retrieval-augmented generation to compensate for the knowledge-timeliness gap.
    • Layered routing. Use a lightweight model for simple tasks like completion and comments, and route architecture design and tough debugging to a more capable model, balancing cost and quality.
    • Prompt caching. Put stable system prompts and project conventions at the front of the input to take advantage of caching and reduce the cost of repeated input.
    • Automatic validation and closed loop. After each generation, automatically run compilation and tests, feed failures back for automatic revision, and turn “people watching people” into “machines gatekeeping.”
    • Usage monitoring and isolated execution. Use logging services and monitoring alerts to track token consumption and call volume per task and per team; run code produced by the agent in an isolated environment following the principle of least privilege.

    When deploying on the cloud, you can directly reuse general-purpose cloud services such as elastic compute, object storage, message queues, container platforms, logging services, and monitoring alerts to lower the cost of building and operating the infrastructure.

    6.2 Common Pitfalls

    1. Using a public question bank as the only benchmark. Public tasks may already have entered the training data through the corpus, which tends to overestimate real capability. Rely mainly on a private question bank and update it regularly.
    2. Ignoring versions and configuration. After the model, runtime, or prompt changes, historical evaluation conclusions may become invalid, so regression testing is needed periodically.
    3. Counting only success cases. The cost of failed cases must be included in the accounting, or cost-effectiveness will be systematically overestimated.
    4. Ignoring data compliance. Both in evaluation and in daily use, code and data should be desensitized to avoid leaking sensitive information.

    7. Conclusion

    Choosing a code LLM is shifting from “experience-driven” to “data-driven.” The method in this article can be summarized in four steps:

    1. Fix the test conditions: Pin the version and runtime, and define rules for no networking, time limits, and timeout handling.
    2. Layer the tasks: Move from self-description and knowledge timeliness to debugging, testing, and comprehensive refactoring, gradually approaching real R&D scenarios.
    3. Score with executable assertions: Use test pass rate, format-compliance rate, and regression results as the primary basis.
    4. Calculate the cost per effective output unit: Convert call cost, rework cost, and elapsed time into a common measure, then compare against the human baseline.

    Back to the original question—“how are the real capability and cost-effectiveness?”: a reliable answer does not come from the impression of a single conversation, but from reproducible experiments and accountable data. Building a sustainable evaluation mechanism, so that every model upgrade has evidence behind it, is where a team’s long-term competitiveness in the era of code intelligence lies.