Let's say 7 has the simpler implementation:
dx = random() * 2 * M_PI;
dy = sin(dx);
dx = cos(dx);
// radius in our dist function
r = random();
r = 1 - sqrt(r);
r = 1 - sqrt(r);
return normalize(forward + (v1 * dx + v2 * dy) * r * sigma);
compared to 5:
dx = random() * 2 * M_PI;
dy = sin(dx);
dx = cos(dx);
// radius in our dist function
r = random();
r = solve_cubic_abcd(-2, 3, 0, -r) * '0 1 0';
return normalize(forward + (v1 * dx + v2 * dy) * r * sigma);
because, the cubic root solving is anything but simple compared to two square roots
So, 7 should be the faster one.
I'll now order them in speed of the code:
0 (277k/sec)
1 (237k/sec)
2 (165k/sec)
6, 7 (158k/sec)
5 (110k/sec)
3, 4 (80k/sec)
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again
You can vary the number of "MS", so you can clearly see it's MS which is causing it.