16 个不稳定版本 (4 个破坏性更新)
0.6.1 | 2023年11月2日 |
---|---|
0.6.0 | 2023年6月5日 |
0.5.1 |
|
0.4.1 | 2023年5月28日 |
0.1.0 | 2022年12月15日 |
#457 在 算法
每月31次 下载
用于 microwfc
23KB
482 行
micro_ndarray
可能是您能找到的具有最佳特性/大小比的最小的 ndarray Rust 实现。您知道 micro_ndarray
几乎比 ndarray
小 100 倍,且没有依赖项(除了 std)吗?
基准测试
考虑到每次基准测试迭代的元素数量,这两种实现都非常快:10_000_000 个相对均匀地分布在数组的维度上。然而,在 7D 时会有所变化,因为 ndarray 只有一种针对最多 7D 的手动快速实现,而 micro_ndarray 则依赖于所有维度的单个实现。这使得它在较小维度上较慢,但在较高维度上要快得多。micro_ndarray 只有一些与维度相关的优化,并且仅限于 1D、2D 和 3D。
所有基准测试均在
CPU: Intel i5-2400 (4) @ 3.400GHz
Memory: 15939MiB
简而言之
micro_ndarray time: [24.460 ms 24.602 ms 24.777 ms]
ndarray time: [6.2882 ms 6.3008 ms 6.3148 ms]
micro_ndarray 3D time: [43.007 ms 43.054 ms 43.101 ms]
ndarray 3D time: [25.750 ms 25.778 ms 25.806 ms]
micro_ndarray 4D time: [47.875 ms 47.958 ms 48.043 ms]
ndarray 4D time: [39.701 ms 39.756 ms 39.810 ms]
micro_ndarray 7D time: [46.657 ms 46.724 ms 46.790 ms]
ndarray 7D time: [1.6210 s 1.6228 s 1.6247 s] <- Boom
按速度排序
ndarray time: [6.2882 ms 6.3008 ms 6.3148 ms]
...
micro_ndarray time: [24.460 ms 24.602 ms 24.777 ms]
ndarray 3D time: [25.750 ms 25.778 ms 25.806 ms]
ndarray 4D time: [39.701 ms 39.756 ms 39.810 ms]
micro_ndarray 3D time: [43.007 ms 43.054 ms 43.101 ms]
micro_ndarray 7D time: [46.657 ms 46.724 ms 46.790 ms] <-\ the difference here is most likely noise
micro_ndarray 4D time: [47.875 ms 47.958 ms 48.043 ms] <-/¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
...
...
[some more ...]
...
...
ndarray 7D time: [1.6210 s 1.6228 s 1.6247 s] <- Boom
详细说明
Running benches/benchmarks.rs (target/release/deps/benchmarks-37dfbc027b120770)
micro_ndarray time: [24.460 ms 24.602 ms 24.777 ms]
change: [+0.8630% +1.4891% +2.2669%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 8 outliers among 100 measurements (8.00%)
4 (4.00%) high mild
4 (4.00%) high severe
ndarray time: [6.2882 ms 6.3008 ms 6.3148 ms]
change: [-0.7727% -0.5346% -0.2994%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
micro_ndarray 3D time: [43.007 ms 43.054 ms 43.101 ms]
change: [-1.1832% -1.0392% -0.8876%] (p = 0.00 < 0.05)
Change within noise threshold.
ndarray 3D time: [25.750 ms 25.778 ms 25.806 ms]
change: [-0.6465% -0.5203% -0.3904%] (p = 0.00 < 0.05)
Change within noise threshold.
micro_ndarray 4D time: [47.875 ms 47.958 ms 48.043 ms]
change: [-0.3193% -0.1150% +0.0840%] (p = 0.27 > 0.05)
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
ndarray 4D time: [39.701 ms 39.756 ms 39.810 ms]
change: [-0.7251% -0.5708% -0.4248%] (p = 0.00 < 0.05)
Change within noise threshold.
micro_ndarray 7D time: [46.657 ms 46.724 ms 46.790 ms]
change: [-0.3268% -0.1459% +0.0485%] (p = 0.14 > 0.05)
No change in performance detected.
Benchmarking ndarray 7D: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 170.6s, or reduce sample count to 10.
ndarray 7D time: [1.6210 s 1.6228 s 1.6247 s]
change: [+0.4095% +1.6176% +2.8514%] (p = 0.01 < 0.05)
Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
如您所见,micro_ndarray 在较高维度上非常一致,而 ndarray 在 2D 上非常快,在 7D 上则非常慢。
依赖项
~25KB