This is actaully a really simple recursion (for-loop), but I'm having some trouble optimizing it so that it would run faster.
Right now it takes around 40-50 seconds to run.
I've already tried loop unrolling, but that didn't optimize it at all.
Loop unrolling:
I'm still new to C++ and out of practice at the moment, I'm sure theres a method out there that could either optimize or replace my recursion but do the same thing, could anyone care to enlighten me?
Thanks.
Code:
for (int i = 0; i < 50; i++)
{
a[i] = getNumber(i);
}
I've already tried loop unrolling, but that didn't optimize it at all.
Loop unrolling:
Code:
for (int i = 0; i < 50; i += 5)
{
a[i] = getNumber(i);
a[i+1] = getNumber(i+1);
a[i+2] = getNumber(i+2);
a[i+3] = getNumber(i+3);
a[i+4] = getNumber(i+4);
}
Thanks.
Comment