Embedded math arithmetic, optimized for small code size at the cost of precision
$ moon bench --target wasm
[applejag/micromath] bench tan.mbt:88 (#3) ok
name time (mean ± σ) range (min … max)
@math.tanf 0.04 µs ± 0.00 µs 0.04 µs … 0.04 µs in 10 × 100000 runs
@micromath.tan 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
[applejag/micromath] bench sqrt.mbt:65 (#2) ok
name time (mean ± σ) range (min … max)
Float::sqrt 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
@micromath.sqrt 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
[applejag/micromath] bench sin.mbt:78 (#1) ok
name time (mean ± σ) range (min … max)
@math.sinf 0.04 µs ± 0.00 µs 0.04 µs … 0.04 µs in 10 × 100000 runs
@micromath.sin 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
[applejag/micromath] bench cos.mbt:83 (#1) ok
name time (mean ± σ) range (min … max)
@math.cosf 0.04 µs ± 0.00 µs 0.04 µs … 0.04 µs in 10 × 100000 runs
@micromath.cos 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
[applejag/micromath] bench atan2.mbt:61 (#1) ok
name time (mean ± σ) range (min … max)
@math.atan2 0.04 µs ± 0.00 µs 0.04 µs … 0.04 µs in 10 × 100000 runs
@micromath.atan2 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
[applejag/micromath] bench atan.mbt:70 (#3) ok
name time (mean ± σ) range (min … max)
@math.atanf 0.07 µs ± 0.00 µs 0.07 µs … 0.07 µs in 10 × 100000 runs
@micromath.atan 0.02 µs ± 0.00 µs 0.02 µs … 0.02 µs in 10 × 100000 runs
Total tests: 6, passed: 6, failed: 0.let DEG_TO_RAD : Floatlet PI : Floatlet RAD_TO_DEG : Floatfn atan(x : Float) -> Floatfn atan2(y : Float, x : Float) -> Floatfn copysign(num : Float, sign : Float) -> Floatfn signum(sign : Float) -> Floatfn sqrt(n : Float) -> FloatInstall
Download zipEmbedded math arithmetic, optimized for small code size at the cost of precision