Repository Public License
1<!--2ORIX Camera3File: docs/development/performance.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->78# Performance910## What has been measured1112Only two things, both on the development Mac (Apple M5 Max, 48 GB, macOS 27.0, release build):13141. the imaging engines, with `orix-bench`;152. the peak memory of bracket fusion, with `/usr/bin/time -l`.1617**Nothing has been measured on an iPhone or iPad.** A Mac's CPU, GPU and memory are not an iPhone's; treat the figures below as proof that the algorithms are cheap relative to a frame interval, not as iPhone numbers.1819### Engines2021`cd Packages/ORIXCameraKit && swift run -c release orix-bench`. Medians. Source: [benchmarks/](benchmarks/).2223| Operation | 1080p | 4K |24|---|---|---|25| Histogram (RGB + luma, every pixel) | 0.98 ms | 2.90 ms |26| Focus analysis (480 px luma plane) | 0.73 ms | 1.74 ms |27| Monitor pass: peaking + zebra + LUT, GPU, including readback | 3.39 ms | 12.26 ms |28| Accumulate one frame (long exposure) | 1.24 ms | 4.98 ms |29| Accumulation preview (float → 8-bit) | 4.21 ms | 16.41 ms |30| Night stack: merge one frame | 4.96 ms | 22.09 ms |31| Night stack: register one frame (Vision) | 2.35 ms | 5.49 ms |3233| Operation | Input | Result |34|---|---|---|35| Bracket fusion | 3 MP × 3 | 130 ms |36| Bracket fusion | 12 MP × 3 | 488 ms |37| Edit recipe render, preview 1600 px | 12 MP | 15 ms |38| Edit recipe render, full size | 12 MP | 18 ms |39| Export JPEG / HEIC / TIFF / PNG | 12 MP | 23 / 58 / 146 / 241 ms |40| Encode H.264 / HEVC / ProRes 422 | 1080p, 120 frames | 153 / 143 / 901 fps |4142Notes: the monitor figure includes reading the texture back to memory, which the live monitor never does. The "resident memory after" lines of the benchmark file are a coarse in-process reading; the fusion memory figures to use are the ones below.4344### Bracket fusion memory4546`/usr/bin/time -l .build/release/orix-bench fusion <megapixels>`, three exposures, maximum resident set size:4748| Size | Peak | Baseline (images only) |49|---|---|---|50| 6 MP | 542 MB | 62 MB |51| 8 MP | 720 MB | 78 MB |52| 12 MP | 929 MB | 109 MB |5354Roughly 75–90 MB per megapixel. Consequence in the app (`CameraModel.fusionPixelBudget`):5556| Physical memory | Fusion working size |57|---|---|58| under 5 GB | 4 MP |59| under 7 GB | 6 MP |60| under 11 GB | 8 MP |61| 11 GB or more | 12.5 MP |6263Whether these tiers are right for iOS's per-app memory limits has to be confirmed on devices.6465### Simulator6667Analysis mode reports delivered frame rate, jitter and analysis time live. In the Simulator these describe the Mac running a timer-driven test scene and are not recorded here.6869## To measure on a device7071| Metric | Method |72|---|---|73| Cold launch to first frame | Xcode Organizer launch metrics; add signposts around `CameraModel.start` and the first `receive(_:)` |74| Time to first preview after a mode or lens change | signposts around `reconfigure` |75| Shutter latency | signpost from `shutter()` to `didFinishProcessingPhoto`; compare `.quality` and `.speed` |76| Capture-to-save | signpost from the delegate callback to `finishIndexing` |77| RAW development time | time `RAWDeveloper.develop` + render on real DNGs, 12 and 48 MP |78| Video frame drops | the recorder's drop count and the capture drop count over ten minutes at each format and codec |79| Histogram and peaking latency | Analysis mode: "Analysis time per frame"; Metal frame time in Instruments |80| Memory | Instruments (Allocations, VM Tracker) in each mode; fusion and night stack peaks |81| Thermal | `systemPressureState` over a long 4K recording; time to "serious" |82| Battery | Instruments energy log over fifteen minutes of preview and of recording |8384Signposts are not in the code yet.8586## Design choices that bound the cost8788| Choice | Effect |89|---|---|90| One Metal pass draws the picture and all aids | one GPU pass per display refresh, no CPU image work for overlays |91| Analysis on a utility queue with a busy flag, at most 12 Hz | analysis can never back up the capture queue |92| Focus score on a 480-pixel luma plane | constant cost whatever the stream size |93| Late video frames discarded by the data output | the pipeline never accumulates latency |94| Accumulators convert row by row into a scratch buffer | working memory is three float planes, nothing more |95| Fusion keeps sources as 8-bit and builds float planes one at a time | lower peak than holding every exposure in float |96| Edit previews are downsized before filtering | interactive sliders on 12 MP+ sources |97| Monitor at 30 Hz under serious thermal pressure | less GPU load when it matters |98| Thumbnails rendered off the main thread and cached | smooth library scrolling |99100## Known costs not yet quantified on a device101102- BGRA conversion of the video stream at 4K60.103- Vision registration plus merge of a 4K frame (about 28 ms on the Mac) exceeds a 30 fps frame interval on slower hardware; the night stack tolerates this because the data output discards late frames, but the burst will span more time.104- ProRes 422 write throughput to internal storage at 4K.105