4 ms·
Yeah, I was wondering that. There could always be the general overhead in the VM, but the HIPE version (which is compiled IIRC) should be closer. A commenter me
by mijoharas 11y ago
Yeah, I was wondering that. There could always be the general overhead in the VM, but the HIPE version (which is compiled IIRC) should be closer. A commenter mentioned that the erlang version would be creating intermediate lists that would have to be garbage collected (see all the lists:seq(0, Div-1) ), but I wouldn't know how to avoid that without writing unidiomatic code. I'm no erlang expert though.
- masklinn 11y agoI don't think the lists would have to be collected, erlang processes have a relatively hefty private heap (233 words) by default, so chances are the process just dies without needing to run a GC[0]. The lists do need to be allocated and initialised though, which may or may not contribute to the runtime. [0] the way I understand it, each process would generate a 10-elements list of small integers, which would be 21 words (1 word + 1 word/element + the sum of the element sizes — 1 word each for small integers)
- mijoharas 11y agoGood point, it would be the allocation, not the GC that would be the problem. My mistake.