How to read these results
Dudu compiles source to C++20. A complete build therefore contains work performed by Dudu and work performed by the configured C++ toolchain. Reporting only the final duration would hide which part costs time and would make optimization results difficult to interpret.
- Frontend
- Lexing, parsing, module resolution, semantic analysis, and diagnostics.
- C++ emission
- Generating module headers, sources, runtime support, and source mappings.
- Native backend
- The external C++ compiler and linker. Dudu currently uses the host toolchain.
- Generated runtime
- The speed and memory use of the finished program after native optimization.
- Cold
- No reusable result for the measured operation. Operating-system file caches remain warm unless noted.
- Incremental
- Only invalidated Dudu modules and native objects are rebuilt.
Generated program runtime
The acceptance criterion is parity with equivalent handwritten C++ using the same data structures, operations, compiler, and optimization flags. The current suite uses GCC 13.3 with -O3 -DNDEBUG and 10,000,000 elements or iterations.
| Benchmark | Dudu median | C++ median | Dudu / C++ |
|---|---|---|---|
| Scalar arithmetic | 8.926 ms | 9.044 ms | 0.987 |
| Pointer traversal | 9.539 ms | 9.293 ms | 1.026 |
| Struct field access | 19.510 ms | 19.472 ms | 1.002 |
| Fixed arrays | 19.349 ms | 19.501 ms | 0.992 |
list / std::vector | 109.968 ms | 110.810 ms | 0.992 |
| Tuple return | 20.197 ms | 21.451 ms | 0.942 |
| Function callback | 41.307 ms | 43.103 ms | 0.958 |
| Particle update | 38.836 ms | 39.369 ms | 0.986 |
| Eight-thread accumulation | 1.568 ms | 1.560 ms | 1.005 |
The observed range is 0.94-1.03 times handwritten C++. The differences are consistent with measurement and code-layout noise. This suite does not demonstrate a systematic Dudu runtime tax for the operations it covers. It is not a claim about every library, allocator, algorithm, or native API.
./scripts/bench.sh 10000000 --samples 5 \
--emit-report build/benchmarks/runtime.jsonCompiler and toolchain comparison
The compiler matrix generates equivalent programs containing primitive fields, records or classes, methods, functions, calls, and an entry point. The reference workload contains 1,000 units. Frontend and executable production are reported separately where each toolchain exposes both operations.
duc emit, including frontend analysisFrontend checking
| Language / operation | Median | p95 | Peak RSS |
|---|---|---|---|
| Dudu frontend | 127.7 ms | 132.4 ms | 63.7 MiB |
Dudu duc emit, frontend included | 219.4 ms | 227.4 ms | 66.4 MiB |
| C++ backend for Dudu output | 256.4 ms | 259.3 ms | 90.7 MiB |
| Dudu complete executable | 477.4 ms | 482.5 ms | 90.7 MiB |
| C++ frontend | 21.7 ms | 23.3 ms | 27.5 MiB |
| C++ executable | 264.8 ms | 269.8 ms | 66.5 MiB |
| Rust frontend | 112.5 ms | 118.1 ms | 101.6 MiB |
| Rust executable | 141.1 ms | 142.1 ms | 124.2 MiB |
| Go frontend | 176.9 ms | 182.9 ms | 210.6 MiB |
| Go executable | 231.1 ms | 251.2 ms | 81.1 MiB |
| Nim frontend | 233.9 ms | 237.4 ms | 35.6 MiB |
| Nim executable | 383.5 ms | 392.6 ms | 39.9 MiB |
| Swift frontend | 342.9 ms | 347.1 ms | 115.1 MiB |
| Swift executable | 1,191.1 ms | 1,268.7 ms | 194.6 MiB |
| C# / MSBuild executable | 865.5 ms | 1,459.9 ms | 149.0 MiB |
Development and incremental build latency
The project-driver fixture contains two Dudu modules and a local native header. Private edits rebuild only the changed generated module. Public interface edits also rebuild dependents. CMake remains responsible for native source and header dependencies.
| Operation | Median | p95 | Peak RSS |
|---|---|---|---|
Tiny duc check | 20.9 ms | 22.2 ms | 54.4 MiB |
| Project no-op check | 20.7 ms | 22.4 ms | 57.3 MiB |
| Generated-CMake no-op build | 72.6 ms | 75.5 ms | 56.3 MiB |
| Generated-CMake no-op run | 72.6 ms | 75.3 ms | 56.1 MiB |
| Generated-CMake no-op test | 72.4 ms | 75.2 ms | 56.0 MiB |
| Private dependency edit | 131.0 ms | 134.1 ms | 57.7 MiB |
| Public interface edit | 159.0 ms | 165.1 ms | 57.8 MiB |
| Native-header edit | 130.4 ms | 134.0 ms | 56.1 MiB |
| Build-configuration edit | 422.1 ms | 440.7 ms | 88.6 MiB |
| Dudu-only no-op module emit | 21.5 ms | 23.0 ms | 57.9 MiB |
| Dudu-only changed-module emit | 22.0 ms | 22.1 ms | 58.1 MiB |
A no-op build still invokes cmake --build. This is the native dependency check that discovers edits to user C and C++ sources and headers. Dudu preserves generated modification times, skips configure, reports zero dirty modules, and lets CMake skip compilation and linking.
Frontend scaling and C++ emission
The broad scaling matrix generates several source shapes so a fast result for one parser pattern cannot hide a slow semantic path elsewhere. It includes inheritance, expressions, multidimensional indexing, operators, native declarations, and multi-module projects.
| Source shape | ~10k lines | ~50k lines | ~100k lines | Clean emit at ~100k |
|---|---|---|---|---|
| Inheritance / abstract dispatch | 33.8 ms | 94.4 ms | 180.4 ms | 389.7 ms |
| Expression-heavy | 71.6 ms | 305.0 ms | 589.6 ms | 940.1 ms |
| Shaped indexing / swizzles | 63.5 ms | 258.5 ms | 502.9 ms | 838.5 ms |
| Overloaded operators | 54.9 ms | 196.8 ms | 375.5 ms | 638.7 ms |
| Native declarations / overloads | 102.0 ms | 436.3 ms | 870.3 ms | 1,490.6 ms |
| Mixed nine-module project | 44.0 ms | 144.3 ms | 289.3 ms | 378.4 ms |
The 50k-to-100k curves are approximately linear. A class-heavy path that previously copied the complete symbol graph for every class took 2,651 ms at 50,000 lines; scoped symbol overlays reduced it to 84.8 ms. Follow-up measurements were 155.3 ms at 100,000 lines and 306.9 ms at 200,000 lines.
Generated output size
The compiler comparison's 10,003 lines of Dudu emit 20,023 lines of inspectable self-contained C++. Of those, 4,005 lines are blank and source-location comments consume 185,962 bytes. Removing comments and blank lines leaves 14,256 lines and 288,680 bytes. The remaining expansion is primarily forward declarations, prototypes, and out-of-line method definitions used to preserve declaration order and module boundaries.
Native-header awareness
Dudu uses Clang to import C and C++ declarations for compilation and editor intelligence. Cold scans pay Clang's header parsing cost. Cached checks load Dudu's serialized native metadata.
| Header graph | Cold check | Cached check |
|---|---|---|
| Small C fixture | 33.6 ms | 8.7 ms |
string + unordered_map + vector | 1,035.0 ms | 48.8 ms |
| 13-header STL fixture | 1,874.5 ms | 114.8 ms |
| SDL3 | 190.0 ms | 36.1 ms |
| raylib | 68.8 ms | 13.3 ms |
Direct imports are scanned as one translation unit, with isolated scans only when headers contain conflicting global declarations. Cached native metadata loading for the large fixture itself takes about 18 ms. Timing output separates libclang, AST dump, AST parse, macro preprocessing, cache, and serialization phases.
Editor latency
Each sample starts a fresh language server. Workspace usability is measured through immediate recovering-parser diagnostics. Full semantic and native diagnostics continue on one coalescing background worker. Warm requests run after project and native indexes are populated.
| Workspace and operation | Median | p95 | Peak RSS |
|---|---|---|---|
raymarch-dd workspace usable | 7.5 ms | 8.0 ms | 280.6 MiB |
raymarch-dd cached first native hover | 219.5 ms | 222.1 ms | 280.6 MiB |
raymarch-dd slowest warm request | 21.0 ms | 22.8 ms | 280.6 MiB |
dudu-webserver workspace usable | 7.5 ms | 7.8 ms | 173.7 MiB |
dudu-webserver cached first native hover | 91.6 ms | 92.3 ms | 173.7 MiB |
dudu-webserver slowest warm request | 11.8 ms | 12.3 ms | 173.7 MiB |
The request probe covers definition, hover, references, completion, semantic tokens, rename, and native-aware hover. With native metadata removed, workspace usability remained 8.2 ms and 7.6 ms; the deliberately native hover then paid a background scan of 3.65 seconds and 1.08 seconds. Native scanning does not block parser diagnostics or unrelated Dudu requests.
Declaration macro compilation
The macro matrix defines 1,000 two-field types and generates one method for each type. Package downloads and the first toolchain dependency bootstrap are excluded. Dudu macro execution itself is about 16 ms; cold application time is dominated by compiling and linking the generated native worker.
| Language | Clean app | Warm app | Unrelated edit | Decorated edit |
|---|---|---|---|---|
| Rust 1.94 | 153.6 ms | 37.3 ms | 88.3 ms | 88.8 ms |
| Dudu | 410.1 ms | 52.5 ms | 53.3 ms | 67.5 ms |
| Nim 1.6 | 819.7 ms | 176.2 ms | 192.6 ms | 194.5 ms |
| Swift 6.3 | 2,160.3 ms | 454.7 ms | 1,404.4 ms | 1,352.9 ms |
| C# / .NET 8 | 2,440.3 ms | 502.8 ms | 1,565.9 ms | 1,592.9 ms |
Dudu's first SDK cache bootstrap is a separate one-time toolchain operation. Macro packages compile into separate translation units and reuse the stable generated SDK support. Warm and edit paths reuse package and expansion caches by content identity.
Reproduce the measurements
Benchmark harnesses generate their fixtures from source, capture exact compiler commands and versions, retain raw samples, and write structured reports under ignored build directories. The published tables are not typed into tests as expected constants; regression thresholds are maintained separately from informational cross-language comparisons.
# Runtime parity
./scripts/bench.sh 10000000 --samples 5
# Compiler and generated-output scaling
./scripts/bench_compiler.sh --build-type Release --samples 3 \
--line-scales 10000,50000,100000 \
--shapes inheritance,expressions,indexing,operators,native,mixed \
--emit-scaling
# Cross-language compiler matrix
python3 scripts/bench_compiler_compare.py --samples 5
# Native headers
./scripts/bench_native_headers.py --samples 5
# Macro comparison
dudu bench compiler -- --suite macros --samples 5 \
--compare rust,csharp,swift,nimCurrent assessment
- Generated runtime performance is in the intended C++ class for the covered operations.
- The Dudu frontend is competitive with the measured modern-language frontends on the 1,000-unit fixture, but GCC checks equivalent C++ substantially faster.
- Complete clean executable production costs more than direct C++ because Dudu adds frontend and emission work before invoking the C++ backend.
- Per-module emission and CMake-backed incremental builds keep the normal edit loop much shorter than a clean self-contained build.
- Cold large C++ header graphs remain visible. Serialized native metadata makes repeated checks substantially cheaper.
- Warm editor requests are responsive in the current dogfood projects. First native symbol queries can still pay background scanning cost when no metadata cache exists.
- The alpha label reflects compatibility, diagnostics, platforms, ABI stability, and ecosystem work. It does not mean generated programs run through an interpreter.