python
numpy: ~3.30ms
numpy with numba: ~2.90ms
node
tfjs: ~1.00ms
gpu.js: ~4.00ms
ndarray: ~118.00ms
vanilla loop: ~138.00ms
mathjs: ~1876.00ms
browser
tfjs webgpu: ~.16ms
tfjs webgl: ~.76ms
tfjs wasm: ~2.51ms
gpu.js: ~6.00ms
tfjs cpu: ~244.65ms
mathjs: ~3469.00ms
c
accelerate.h: ~.06ms
Source here: https://github.com/raphaelrk/matrix-mul-test t0 = new Date();
a = Array(100000000).fill(0);
console.log("time elapsed: ", new Date() - t0); // 22912
a[100000] = 1;
a[10000000] = 1;
a.forEach(e => e == 1 && console.log(e));
console.log("time elapsed: ", new Date() - t0); // 28371
t1 = new Date();
a = Array(100000000);
a[100000] = 1;
a[10000000] = 1;
a.forEach(e => e == 1 && console.log(e));
console.log("time elapsed: ", new Date() - t1); // 2787
Upon doing a couple not-so-scientific runs of this, it looks like the latter isn't really faster than the former.