How to Evaluate LLM Code Generation with a Hard Engineering Benchmark

    Generic coding puzzles often misrepresent how well an AI coding tool performs in real projects. This article describes a repeatable benchmark: implement a classic top-down tank shooter as a UEFI Shell application with no OS, graphics library, or audio stack. It covers the task spec, a five-stage evaluation process, why the build environment is the real dividing line, a fixed prompt template, scoring dimensions, and practical conclusions.

    1. Why a Hard Benchmark Is Needed

    Measuring an AI coding tool with generic algorithm problems or a few lines of script often produces misleading results. The hard part of real engineering is not syntax. It is system integration under constraints: an unfamiliar platform, a missing ecosystem, a complex build chain, and no ready-made reference solution.

    For that reason, I have long used the same benchmark for side-by-side comparison: implement a classic top-down tank shooter from scratch in a firmware Shell environment with no operating system, no graphics library, and no audio stack (gameplay modeled on a classic 8-bit design). I have already used this task to evaluate several China-based large language models. This article completes the last step of that comparison and summarizes the method.

    There are three reasons for choosing this task:

    • Extreme environment. The runtime is a Unified Extensible Firmware Interface (UEFI) Shell application. Graphics can only be produced by writing the frame buffer directly through the Graphics Output Protocol (GOP). There is no window system and no third-party rendering library.
    • Moderate scale. A complete implementation needs thousands of lines of structured code, including a state machine, collision detection, pathfinding, and a particle system. That is enough to expose long-range consistency failures.
    • Automatable acceptance. Whether it compiles, whether it boots, whether the frame rate is stable, and whether the features are complete can all be measured.

    2. Defining the Benchmark Spec

    The task description must be precise enough to accept or reject, or results will not be comparable. The requirements baseline I use is:

    • Runtime: a pure software application under the UEFI Shell. Graphics use GOP, 640×480 resolution, BGRA pixel format, and a stable target of 30 frames per second.
    • Core gameplay: a fixed top-down map; player tank movement and shooting; enemy tanks spawning in waves; a base icon to protect; destructible brick walls; items such as invincibility, armor-piercing rounds, and extra lives; clearing every wave wins the game.
    • Content scale: 8 maps, 4 enemy tank types, 5 item types, and a particle-effects system.
    • Explicit exclusion: no audio.

    Exclusions matter as much as requirements. If you do not state what not to do, the model will add unrelated modules such as audio initialization or file-system dependencies and break the build.

    3. A Five-Stage Evaluation Process

    I split evaluation into five stages. Each stage is billed and judged separately, so a single large run does not hide where the failure occurred.

    1. Requirements document. Send an /init-style instruction and ask for a project description in Chinese. This stage is very cheap. It mainly tests whether the model can turn a fuzzy request into a constraint list.
    2. Build environment. Place the code in the simulator project directory of a firmware development kit and build it with the local compiler. This is the real dividing line.
    3. Runtime switch. If the simulator project build is blocked, explicitly instruct the model to switch to an open-source virtual machine plus a generic firmware boot image for debugging.
    4. Feature completion. Fill in maps, enemy types, items, and effects one by one against the requirements list.
    5. Regression. Rebuild and rerun to confirm that nothing has regressed.

    4. Key Observation: The Build Environment Is the Dividing Line

    Across seven tests, only two models completed stage 2. The rest stalled. The stall pattern was highly consistent and worth analyzing on its own:

    • Repeated small edits to the project description and the firmware image description.
    • Trial-and-error loops over dependencies, changing only one or two parameters each time.
    • Compile errors that do not decrease while token use keeps rising.
    • No initiative to propose a different technical path.

    This exposes a shared weakness: models lack a notion of sunk cost and keep investing in a wrong path. The correct engineering move is for a human to cut losses and downgrade the problem from “fix the build system” to “change the runtime.” That instruction should be short and explicit:

    1. Stop building the simulator project. Debug and run by loading the firmware image on a virtual machine platform.
    2. Keep the existing application code. Only adjust the build and startup scripts.

    After the switch, most models quickly resume producing output. The failure is therefore not a coding-ability problem. It is a problem of environment reasoning and strategy switching.

    The entry structure of a firmware application is not complicated. A competent output should look roughly like this:

    1. EFI_STATUS EFIAPI UefiMain (
    2. IN EFI_HANDLE ImageHandle,
    3. IN EFI_SYSTEM_TABLE *SystemTable
    4. )
    5. {
    6. // 1. Locate the GOP protocol, set 640x480 BGRA mode, and get the frame buffer base
    7. // 2. Allocate a double buffer and lock a 30 FPS cadence (driven by an event timer)
    8. // 3. Main loop: scan input -> update logic -> render -> swap buffers
    9. // 4. On exit, release resources and return EFI_SUCCESS
    10. }

    5. Prompt Template Essentials

    Prompts must stay fixed if different models are to be comparable. A recommended structure:

    1. [Platform constraints] UEFI Shell application. Only firmware interfaces and the GOP protocol may be used. Do not introduce external libraries.
    2. [Feature list] Number each item. This list is the acceptance basis.
    3. [Non-goals] No audio, no network, and no file storage.
    4. [Build approach] Try plan A first. After two failures, switch to plan B on your own and explain why.
    5. [Output requirements] Provide complete code split across files. No pseudocode placeholders.

    The rule “switch paths after two failures” measurably reduces useless loops.

    6. Suggested Scoring Dimensions

    Dimension Weight How to judge
    Build success 30% Compiles with zero manual intervention
    Runtime stability 20% Frame rate meets the target and the app does not crash
    Requirements coverage 25% Check each item on the list
    Resource efficiency 15% Token volume required to reach the same result
    Strategy switching 10% Whether it changes path on its own when blocked

    7. Common Mistakes and Conclusions

    • Judging only the demo. A nice animation does not mean the code is maintainable. Inspect structure and resource-release paths.
    • One very long prompt. Longer requirements are easier to miss. Feeding them in stages is more reliable.
    • Ignoring cost. At equal capability, token efficiency decides whether the model can enter a daily pipeline.
    • Skipping regression. Model edits often introduce regressions. Regression checks are not optional.

    The conclusion is direct. To evaluate an LLM’s coding ability, the task must be hard enough, the constraints must be clear, the work must be staged, and losses must be cut quickly. Getting a build environment working predicts real engineering usefulness better than scores on algorithm problems. When a model falls into a useless loop, one decisive human route change is often more effective than spending more budget.