# Benchmarks

Measured results of one CPU, rendering and list-load suite run inside a Compose desktop app on the JVM, GraalVM Native Image, SwiftUI, Tauri and Flutter.

The [`benchmark-demo`](https://github.com/NucleusFramework/Nucleus/tree/main/examples/benchmark-demo)
example runs one suite inside a Compose desktop app: 13 CPU kernels, three rendering ramps and a
list-load test. The same kernels are ported to SwiftUI, Tauri and Flutter. Every variant ran on an
Apple M4 on 2026-07-16.

Higher is better for CPU and GFX; lower is better for list, peak RAM and app size. Composite
scores compare only within this suite.

## Summary

Sorted by composite CPU score.

| # | Variant | Runtime | CPU | GFX | list (ms) | Peak RAM | App size |
|---|---------|---------|----:|----:|----------:|---------:|---------:|
| 1 | **jvm-graal** | GraalVM 25.0.3 JIT + ProGuard | 146.7 | 13041 | 21.0 | 695 MB | 160 MB |
| 2 | **tauri** | Rust + WebView (WKWebView) | 142.2 | 15013 | 233.0 | 794 MB † | 5.6 MB ‡ |
| 3 | **jvm-c2-pg** | OpenJDK 26 C2 + ProGuard | 140.4 | 13041 | 20.9 | 616 MB | 119 MB |
| 4 | **swiftui** | Swift/LLVM + SwiftUI | 138.7 | 15254 | 14.4 | 268 MB | 0.34 MB ‡ |
| 5 | **jvm-c2** | OpenJDK 26 C2 (no ProGuard) | 138.5 | 13041 | 21.6 | 620 MB | 136 MB |
| 6 | **aot-o3-pgo** | GraalVM Native `-O3` + PGO | 132.7 | 13859 | 17.1 | 269 MB | 129 MB |
| 7 | **aot-o3** | GraalVM Native `-O3` (ML-inferred) | 100.8 | 13859 | 17.1 | 297 MB | 174 MB |
| 8 | **aot-o2** | GraalVM Native `-O2` | 86.9 | 11239 | 17.2 | 278 MB | 150 MB |
| 9 | **aot-os** | GraalVM Native size-opt (`-Os`) | 80.1 | 10433 | 17.3 | 326 MB | 129 MB |
| 10 | **flutter** | Dart AOT + Impeller | 57.3 | 15133 | 17.2 | 196 MB | 37 MB |

† Includes the WebKit processes; an upper bound. ‡ Excludes the system engine (SwiftUI and AppKit,
or WebKit), so it does not compare directly with the variants that ship their runtime.

## Read the results

- **CPU.** GraalVM JIT scores highest (146.7). Tauri (142), SwiftUI (139) and OpenJDK C2 (138 to
  140) sit close together. GraalVM Native reaches that group only with PGO (100.8 to 132.7).
- **PGO.** `aot-o3-pgo` reaches 132.7 CPU with 269 MB of peak RAM, against 616 to 695 MB for the
  JVM variants. The cost is the PGO workflow: an instrumented build, a GUI run, then a rebuild.
  The profile also shrinks the image from 174 MB to 129 MB.
- **RAM.** Flutter uses the least (196 MB), then SwiftUI (268) and GraalVM Native (269 to 326).
  The JVM variants use 616 to 695 MB, and Tauri 794 MB (†).
- **List load.** GraalVM Native takes about 17 ms, the JVM about 21 ms, SwiftUI 14 ms and Tauri
  233 ms.
- **Flutter** has the lowest CPU score (57.3) but one of the highest GFX scores (15133).

## Per-kernel CPU

Throughput, higher is better.

| Kernel | jvm-graal | tauri | jvm-c2-pg | swiftui | jvm-c2 | aot-o3-pgo | aot-o3 | aot-o2 | aot-os | flutter |
|--------|----:|----:|----:|----:|----:|----:|----:|----:|----:|----:|
| mandelbrot | 4.09 | 4.13 | 4.33 | 3.92 | 3.99 | 1.98 | 3.32 | 1.97 | 3.27 | 3.61 |
| nbody | 700.6 | 693.2 | 639.6 | 659.4 | 691.3 | 694.7 | 683.0 | 654.8 | 678.3 | 608.7 |
| raytracer | 17.2 | 19.8 | 18.9 | 19.8 | 19.0 | 17.5 | 15.8 | 14.0 | 7.0 | 4.2 |
| matmul | 14217 | 16224 | 16690 | 16215 | 16724 | 12225 | 3877 | 3244 | 3105 | 3054 |
| blur | 93.4 | 44.5 | 59.7 | 80.7 | 49.2 | 91.5 | 49.5 | 46.6 | 36.5 | 30.0 |
| sha256 | 332.9 | 442.1 | 361.2 | 360.3 | 361.7 | 326.9 | 296.8 | 294.9 | 268.2 | 192.4 |
| sieve | 708.5 | 642.3 | 565.9 | 603.6 | 599.9 | 725.9 | 467.2 | 463.2 | 484.4 | 268.6 |
| fft | 407.8 | 452.7 | 441.5 | 436.9 | 441.1 | 363.9 | 369.6 | 376.3 | 356.8 | 366.9 |
| pi | 0.09 | 0.11 | 0.11 | 0.11 | 0.10 | 0.10 | 0.09 | 0.09 | 0.09 | 0.08 |
| mandelbrot_mt | 15.5 | 16.5 | 15.6 | 16.1 | 16.1 | 14.5 | 14.1 | 7.5 | 12.2 | 10.6 |
| raytracer_mt | 74.5 | 81.2 | 68.6 | 75.0 | 67.2 | 71.4 | 60.2 | 49.9 | 25.5 | 13.7 |
| matmul_mt | 62088 | 69442 | 64038 | 33013 | 63925 | 60113 | 19988 | 17255 | 15956 | 9731 |
| blur_mt | 345.0 | 188.4 | 244.1 | 261.7 | 238.3 | 285.9 | 203.5 | 194.4 | 155.1 | 40.0 |

## Render ramps

Highest load sustained at 55 fps or more, higher is better.

| Variant | Particles | Stars | Texts |
|---------|----:|----:|----:|
| swiftui | 125000 | 18175 | 3906 |
| aot-o3 / o3-pgo | 75000 | 14540 | 6102 |
| jvm (×3) | 50000 | 18175 | 6102 |
| flutter | 50000 | 18175 | 9533 |
| aot-o2 | 50000 | 11632 | 6102 |
| aot-os | 50000 | 9306 | 6102 |
| tauri | 25000 | 18175 | 18618 |

## Reproduce

```shell title="terminal"
cd examples/benchmark-demo

# JVM and native matrix
JAVA_HOME=<jbr-21> GRAALVM_HOME=<graalvm-25> JDK_C2_HOME=<jdk-26> \
  ONLY="jvm-c2 jvm-c2-pg jvm-graal aot-os aot-o2 aot-o3 aot-o3-pgo" ./run-all.sh

# Ports
ONLY="swiftui tauri flutter" ./run-all.sh
```

Run the native builds with `JAVA_HOME` pointing at GraalVM, or Gradle may pick a cached Oracle
JDK 25 without `native-image` and the compile fails. Each variant writes a result JSON, and the
example's `RESULTS.md` holds the full per-variant appendix.

- **Setup:** Apple M4, 10 cores, on AC power. Oracle GraalVM 25.1.3+9.1 (Java 25.0.3), OpenJDK
  26.0.1, Gradle daemon on JBR 21.
- **Protocol:** 3 discarded warmups, then the best of 5 over the CPU kernels. Variants run one at
  a time in one session, peak RSS is sampled during each run, and every self-check passes.
- **Tauri (†):** the Tauri process alone has a 177 MB RSS. The 794 MB sums the WebKit processes
  (`WebContent`, `GPU`, `Networking`) and counts shared `WebKit.framework` pages more than once.
  Its list goes through the DOM and a canvas.
- **Kernels:** without PGO, `matmul` drops to 3877 MFLOP/s against 12225 with it. Graal does well
  on `blur` and `sieve`, less well on `fft` and `sha256`, and PGO regresses `mandelbrot` (1.98
  against 3.32).
- **Reproduce:** Gradle picks the wrong JDK because a cached Oracle JDK 25 matches the
  `vendor=ORACLE`, `version=25` toolchain spec.

## What's next

- [GraalVM Native Image](/docs/performance/graalvm): what a native image changes for a Nucleus app.
- [Optimize with a PGO profile](/docs/performance/graalvm/configuration#optimize-with-a-pgo-profile): the setup behind `aot-o3-pgo`.
- [AOT cache](/docs/performance/aot-cache): faster startup on the JVM path.
