4 ms·
Probably because Go version is different, compare C vector operations with Go vector operations. C version is operating on pointer without allocating new vector
by lossolo 8y ago
Probably because Go version is different, compare C vector operations with Go vector operations. C version is operating on pointer without allocating new vector, Go version is allocation new vector on every op.
EDIT: Look at C code assembly, it's generating mostly SIMD instructions and using xmm registers. That's why it's faster. Golang compiler still do not have autovectorization implemented that's why it's so much slower in this case.
EDIT2: It seems Go version also uses SSE here, which is nice. So probably unnecessary allocation from my original post was the reason.
- weberc2 8y agoI modified the Go version to pass references (see my second edit) and that made up the difference (or I mistranslated).