OnlyCSharp Micro-Benchmarks
Real steady-state micro-benchmarks from the optimization_agent_loop harness (min-of-3 estimator, xorshift64 inputs, 4096-cycle, TieredCompilation off). This page runs the Mathematics.Fast.Math (OcMath) benchmark group live at build time and renders the measured result tables. Timings are a machine-and-run-dependent snapshot; only OcMath is shown to keep the build bounded. No JavaScript, no WASM.
A. Wrapper overhead (app-used intrinsics): OcMath vs System.Math
| Method | Variant | ns/op | ops/s | Note |
|---|---|---|---|---|
| Sqrt(double) | OcMath.Sqrt | 3.495 | 286,158,895 | |
| Sqrt(double) | System.Math.Sqrt | 3.488 | 286,679,659 | |
| Sin(double) | OcMath.Sin | 3.400 | 294,127,163 | |
| Sin(double) | System.Math.Sin | 3.344 | 299,001,038 | |
| Cos(double) | OcMath.Cos | 3.298 | 303,256,827 | |
| Cos(double) | System.Math.Cos | 3.373 | 296,483,410 | |
| Pow(double) | OcMath.Pow | 7.394 | 135,251,561 | |
| Pow(double) | System.Math.Pow | 7.439 | 134,433,266 | |
| Log(double) | OcMath.Log | 2.534 | 394,569,929 | |
| Log(double) | System.Math.Log | 2.528 | 395,577,444 | |
| Abs(double) | OcMath.Abs | 0.390 | 2,565,457,652 | |
| Abs(double) | System.Math.Abs | 0.357 | 2,804,592,801 |
B. Pure-software app-used helpers (OcMath only)
| Method | Variant | ns/op | ops/s | Note |
|---|---|---|---|---|
| Clamp(double) | OcMath.Clamp | 0.412 | 2,425,194,864 | |
| Lerp(double) | OcMath.Lerp | 0.357 | 2,800,061,601 | |
| Max(double) | OcMath.Max | 0.386 | 2,589,586,754 | |
| SmoothStep(double) | OcMath.SmoothStep | 0.517 | 1,933,241,311 |
C. Optimization candidates (current vs proposed vs ns2.1 ceiling)
| Method | Variant | ns/op | ops/s | Note |
|---|---|---|---|---|
| Log2(double) | OcMath.Log2 [Math.Log(x,2)] | 2.568 | 389,397,485 | |
| Log2(double) | proposed [Log(x)*Log2E] | 2.566 | 389,721,486 | max|Δ| vs current = 0.00E+000 |
| Log2(double) | ceiling [Math.Log2 net8] | 3.650 | 273,967,724 | |
| Log2(float) | OcMath.Log2 [Log(x)/Log(2f)] | 2.004 | 498,985,811 | |
| Log2(float) | proposed [Log(x)*Log2Ef] | 1.992 | 502,117,681 | max|Δ| vs current = 0.00E+000 |
| Log2(float) | ceiling [MathF.Log2 net8] | 1.879 | 532,212,140 | |
| Exp2(double) | OcMath.Exp2 [Pow(2,x)] | 2.200 | 454,483,480 | |
| Exp2(double) | proposed [Exp(x*Ln2)] | 2.103 | 475,549,616 | max|Δ| vs current = 0.00E+000 |
| Sin+Cos(double) | OcMath.Sin+Cos (renderer path) | 8.857 | 112,909,381 | |
| Sin+Cos(double) | fused Math.SinCos (net-core) | 9.588 | 104,295,841 | blocked by ns2.1 target |