4 ms·
Seems more like a test of the speed of the random number generator. Never mind that the JS version doesn’t use “slice” to copy the array… Edit: they’re not eve
by schemescape 4y ago
Seems more like a test of the speed of the random number generator. Never mind that the JS version doesn’t use “slice” to copy the array…
Edit: they’re not even using the same data types in the arrays. Very misleading. I would caution against drawing any conclusions from this article.
Edit again: someone pointed out that the random number generation happens in an outer loop, so probably not a big impact. The point about slice still stands.
- zRedShift 4y agoIt's also not measuring rng speed, it's measuring memcpy and sort speed.
- schemescape 4y agoNot sure I follow. Math.random() is in testSort, so the time to generate the random numbers is part of the measurement (even though it almost certainly shouldn’t be). Edit: my main point is that there are many flaws in this comparison, so I wouldn’t draw any conclusions from the measurements in the article. They’re pretty much meaningless.
- zRedShift 4y agoI agree, but what I'm saying is, it only generates the numbers once and then sorts them 500 times. Yes it's a flawed measurement because it measures the generation time + 500 sorts, but the time to generate the numbers is probably minuscule compared to the sorting. There are many more flaws, as you say, the biggest flaw is the stable vs unstable sort comparison, but it looks like the article author (not OP) has fixed it half an hour ago and updated the article.
- schemescape 4y agoYou’re right, it uses the same array 500 times and then runs an outer loop (with a new array each time) 5 times.