Repository Public MIT
1<!--2ORIX Calc3File: docs/development/performance.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Performance89All numbers on this page were measured; none are estimates. They come from `Benchmarks/` (`swift run -c release orix-bench`),10a command-line harness that calls the engine packages directly. The raw output of the last run is in11[`benchmark-results.md`](benchmark-results.md).1213**What these numbers are:** engine time on the development Mac named in the table header, release build, single thread,14median wall-clock of repeated runs. **What they are not:** on-device measurements. An iPhone is slower than this Mac by a15device-dependent factor; cold launch, memory and battery were not measured (see "Not measured").1617## Engine measurements1819Machine: Apple M5 Max, 18 cores, macOS Version 27.0 (Build 26A5425a)20Build: release, single thread, wall-clock median of repeated runs2122| Benchmark | Median | Best | Runs | Notes |23|---|--:|--:|--:|---|24| Parse + evaluate `25 × 4` | 38.8 µs | 17.8 µs | 2000 | |25| Parse + evaluate `0.1 + 0.2` (exact rational) | 50.9 µs | 25.1 µs | 2000 | |26| Parse + evaluate `sin(30)^2 + sqrt(2) * ln(10)` | 92.7 µs | 42.6 µs | 2000 | |27| Full run with explanation and verification `(1234.5 + 6) * 7 / 8 - 9^2` | 99.8 µs | 53.0 µs | 2000 | |28| `100!` exact (158 digits) | 82.8 µs | 36.7 µs | 2000 | |29| `2000!` exact (5 736 digits) | 689.1 µs | 479.4 µs | 351 | |30| `sum(1/k^2, k, 1, 1000)` exact rational sum, falls back to double past 8192 bits | 152.50 ms | 145.32 ms | 7 | |31| `integral(exp(-x^2), x, -inf, inf)` adaptive quadrature | 80.4 µs | 39.1 µs | 2000 | |32| Compiled function: 100 000 evaluations of sin(x)² + e^(−x/3)·√|x| | 4.10 ms | 3.73 ms | 60 | |33| Determinant 20 × 20, exact rational arithmetic | 8.81 ms | 8.11 ms | 28 | |34| Determinant 50 × 50, exact rational arithmetic (decimal entries) | 437.67 ms | 410.47 ms | 5 | |35| Determinant 50 × 50, floating point | 10.82 ms | 9.44 ms | 23 | |36| Inverse 50 × 50, floating point (with residual check) | 27.33 ms | 25.45 ms | 9 | |37| Product 50 × 50 · 50 × 50, floating point | 13.52 ms | 12.51 ms | 18 | |38| Eigenvalues 50 × 50 (LAPACK dgeev) | 4.14 ms | 3.66 ms | 59 | |39| Workspace: open and compute 501 linked cells | 289.38 ms | 281.07 ms | 5 | |40| Workspace: move a slider that 500 cells depend on | 1.21 s | 1.08 s | 5 | |41| Workspace: edit a leaf cell (1 cell recalculated out of 501) | 14.04 ms | 12.39 ms | 16 | |42| Workspace: move a slider that 500 floating-point cells depend on | 17.48 ms | 14.85 ms | 14 | |43| Workspace: move the DiscountRate slider of a 14-cell NPV sheet | 1.59 ms | 1.08 ms | 119 | |44| Workspace: export 501 cells to LaTeX | 680.08 ms | 466.75 ms | 5 | |45| Mortgage payment (Canadian convention) | 17.6 µs | 16.1 µs | 2000 | |46| Amortization schedule, 300 payments, cent-exact | 2.82 ms | 1.59 ms | 45 | |47| IRR of 241 cash flows (all real roots searched) | 17.5 µs | 16.8 µs | 2000 | |48| Black–Scholes–Merton price | 33.1 µs | 30.6 µs | 2000 | |49| Implied volatility | 21.0 µs | 19.2 µs | 2000 | |50| American put, binomial tree, 1 000 steps | 529.8 µs | 503.6 µs | 224 | |51| Monte Carlo, 1 000 000 normal trials, seeded | 561.69 ms | 519.90 ms | 7 | |52| Multiple regression, 10 000 rows × 3 predictors, with diagnostics | 2.21 ms | 1.46 ms | 48 | |53| Quantile of 10 000 values | 586.7 µs | 540.2 µs | 84 | |54| Student t quantile (inverse incomplete beta) | 2.0 µs | 1.9 µs | 2000 | |55| Graph: sample `sin(x)` at 1200 × 800 with discontinuity detection | 177.5 µs | 141.9 µs | 774 | |56| Graph: sample `tan(x)` at 1200 × 800 with discontinuity detection | 683.8 µs | 446.8 µs | 207 | |57| Graph: sample `1/x` at 1200 × 800 with discontinuity detection | 236.8 µs | 175.5 µs | 690 | |58| Graph: sample `sin(100x)` at 1200 × 800 with discontinuity detection | 2.26 ms | 2.03 ms | 26 | |59| Graph: implicit curve x² + y² = 25 at 1200 × 800 | 5.75 ms | 3.85 ms | 19 | |60| Graph: 60 × 60 surface mesh of sin(x)·cos(y) with normals | 670.5 µs | 658.1 µs | 172 | |61| Unit conversion, exact decimal (mi → km) | 2.4 µs | 2.3 µs | 2000 | |6263## Reading the results6465- **Everyday arithmetic** is tens of microseconds including parsing. The figure includes the start of a dedicated66 large-stack thread for each evaluation (see `DeepStack`), which is most of the cost of a trivial expression.67- **Exact arithmetic costs what it computes.** `2000!` (5 736 digits) takes well under a millisecond. Sums of many fractions68 with unrelated denominators grow quickly: `sum(1/k², k, 1, 1000)` is exact until the fraction passes 8192 bits, then69 continues in floating point with a precision note; it is the slowest expression in the table and runs off the main thread.70- **Linear algebra**: floating-point 50 × 50 operations take milliseconds. Exact 50 × 50 elimination on decimal entries takes71 around a second because every pivot step reduces large fractions; it is cancellable and off the main thread.72- **Workspace**: a slider on a typical sheet (the 14-cell NPV model) recalculates in under 2 ms, well inside a 120 Hz frame.73 A 500-cell floating-point dependency chain recalculates in one to two frames. The pathological case — 500 cells that each74 compound an exact rational, so that every value has thousands of bits — takes about a second per change; it is listed in75 Known Limitations.76- **Graphing**: sampling a function across 1200 pixel columns with discontinuity detection takes a fraction of a77 millisecond; a function that oscillates faster than the screen can show is detected and drawn as a band in about 2 ms.7879## Optimisations made from profiling8081| Finding (from the benchmark and `sample`) | Change |82|---|---|83| Verification notes built their message text inside arithmetic inner loops | The text is now built only when the note is first recorded |84| Moving a workspace slider re-parsed every cell | A fast path updates the parameter's literal and re-evaluates only its dependents |85| The dependent-cell search was quadratic | Reverse index + breadth-first closure |86| A "floating-point" matrix benchmark was in fact exact (decimal literals are exact by design) | The benchmark now measures both cases separately |87| Long sums overflowed small thread stacks | Evaluation runs on a 64 MB stack; chains are bounded at 1000 terms; long chains compile to loops |8889## Responsiveness design9091- Committed evaluations, live previews, binomial trees, Monte Carlo runs, bootstrap, ODE solves, sweeps and graph sampling92 run off the main actor; the main actor only applies results.93- Latest-wins cancellation is used wherever input changes faster than results (previews, sliders, pan and zoom).94- Graph gestures redraw immediately from the previous samples and refine when new samples arrive.9596## Not measured9798Cold launch time, memory footprint, energy use and frame rate on physical devices. No physical device was connected during99development; these must be measured with Instruments on real hardware before public release.100