How to Evaluate LLM Code Generation: A Reproducible Benchmark and Lessons from Chinese Models

    This article presents a practical method for evaluating the coding ability of large language models without relying on cherry-picked demos. It explains why "evaluate on release day" produces unreliable results, how to design a single fixed benchmark task in a bare-metal firmware shell environment, and how to run a versioned, parameter-controlled experiment with a five-round repair limit and manual acceptance checks. A four-layer scoring model covering instruction following, first-pass success, debugging efficiency, and engineering quality is described, along with common pitfalls and suggestions for building an internal evaluation pipeline. The goal is a repeatable process that turns model output into testable deliverables for long-term model selection.

    1. Why “Evaluate on Release Day” Is Misleading

    Whenever a new generation of large language models ships, social media fills up with scattered screenshots first: a nice one-shot generation, a seemingly complex algorithm snippet. The fatal problem with these samples is that they are not reproducible. The prompt, context length, temperature setting, and whether reasoning mode was enabled are all unrecorded, so switching machines or starting a new session can lead to a completely different conclusion.

    An evaluation with real engineering value needs to satisfy three conditions: a fixed task, a recordable process, and results that can be verified by running the code. Only when “model behavior” is converted into “did the deliverable pass the tests” does the discussion become comparable.

    2. Benchmark Design: One Unified Task Beats Many Tasks

    For a long time I used the same benchmark task to observe different models side by side: implement a classic mini-game from scratch in a firmware shell environment with no operating system. The reasons for choosing this kind of task are specific:

    • Extreme environment: There is no standard runtime and no third-party graphics library, only the most basic text output and key input capabilities. The model cannot get by by relying on “library calls it remembers.”
    • Clear constraints: Requirements such as memory layout, character buffering, timed refresh, and non-blocking input are written down explicitly, so right and wrong are obvious.
    • Layered acceptance: Whether it compiles, whether it runs, whether the logic is correct, and whether the experience is smooth form a clear progression for scoring.

    It is worth emphasizing that this kind of low-level task does not test whether a model “knows how to write a loop.” It tests whether the model can proactively clarify constraints when information is insufficient, and whether it strictly respects interface boundaries that do not exist. Many models invent non-existent drawing functions in the first round, and this is exactly the most valuable observation point.

    3. Experiment Workflow: Turning Subjective Impressions into Data

    To keep the conclusions credible, I fixed the following workflow, and readers are encouraged to reproduce it:

    1. Version the prompt: Write the requirement description into a file and put it under version control. Every change leaves a record, and unverifiable additions in the session such as “you forgot to consider…” are forbidden.
    2. Fix the parameters: Keep temperature, maximum output length, and whether extended thinking is enabled consistent. If a model offers multiple modes, record them as separate groups and do not mix them with the default mode.
    3. Cap the iterations: Allow at most five repair rounds, and track two metrics: the “first-pass compile rate” and the “pass rate within five rounds.” The gap between them reflects self-correction ability.
    4. Manual acceptance: A person runs the code against the same checklist and records crashes, logic errors, and experience defects, avoiding the optimistic bias of model self-assessment.
    5. Record cost: Track total input and output volume and elapsed time to produce a “cost per unit of effective output,” which reflects real spending better than unit price does.

    A sample acceptance checklist can be abstracted as:

    1. [ ] Compiles with zero errors and zero fatal warnings
    2. [ ] Screen is stable after launch, no random crashes
    3. [ ] Input response has no lag and supports interruption
    4. [ ] Edge cases (full screen, out of bounds, exit) handled correctly
    5. [ ] All fixes completed within five rounds

    4. Scoring Dimensions: Four Layers Instead of One Total Score

    A single total score hides differences in capability structure. I use a four-layer evaluation:

    Layer 1: Instruction following. Does the model work strictly within the given constraints, or does it introduce modules that do not exist on its own? This layer carries the highest weight, because in real engineering the rework cost of hallucinated interfaces far exceeds code style problems.

    Layer 2: First-pass success rate. The proportion of first outputs that compile and run directly, reflecting the model’s knowledge coverage of niche environments and the robustness of its reasoning.

    Layer 3: Debugging efficiency. Given a compile error log, can the model pinpoint the problem accurately rather than rewriting broadly? A good result is a minimal change that touches only the relevant functions; a poor result is starting over and introducing new problems.

    Layer 4: Engineering quality. Whether naming is consistent, whether state and rendering are separated, whether magic numbers exist, and whether long functions are split. This layer determines whether the code can be taken over and maintained by a person.

    5. Common Pitfalls and How to Avoid Them

    • Demo instead of acceptance: Only running and repeatable running counts as a pass.
    • Ignoring context contamination: Repeatedly appending requirements in the same session inflates later performance, so open a new session and retest.
    • Testing generation but not maintenance: Append one small requirement change and observe the scope of the modification; this effectively identifies output that is too tightly coupled.
    • Overlooking cost structure: The gains from long reasoning modes must be accounted for together with latency and consumption, especially for batch code tasks.

    6. Recommendations for Engineering Adoption

    For teams, I recommend turning the workflow above into an internal evaluation pipeline: check the benchmark task and checklist into a repository, wrap model calls through a unified gateway so models can be switched easily, archive results automatically to object storage, and build a metrics dashboard on top of log services and monitoring alerts. If batch generation is involved, a container platform can provide isolation and concurrency control, and a message queue can smooth out peaks. In these scenarios Baidu AI Cloud typically provides general-purpose capabilities, and the specific choice should still be based on your own load test data.

    7. Conclusion

    To evaluate the coding ability of a new generation of models, the key is not whether it can produce nice snippets, but stability and correctability under harsher constraints. A fixed benchmark, a reproducible workflow, layered scoring, and cost accounting together make conclusions stand the test of time. For developers, rather than chasing leaderboard rankings, it is better to build your own benchmark set, which is the most reliable asset for long-term selection and upgrade decisions.