|
|
|
|
|
by Athas
3377 days ago
|
|
Turning the recursive formulation of the Fibonacci function into an iterative loop is not easy for a compiler (unless you just program that specific pattern into it). However, this "benchmark" is totally dominated by function call overhead, and it's quite conceivable that you can engineer your compiler to optimise for that case at the expense of others. You could do it quickly enough by unrolling the recursion a few times. This can cause the code to balloon in size in the general case, but not for this simple case. It's also not particularly impressive to optimise a Javascript program that does not exhibit any complex behaviour. Again, you can just write a compiler that detects whether the Javascript program is straightforward, and if so, turns it into C or whatnot. Without being able to see what the compiler is doing, there is no way to know. Also, "Compiler as a Service" may be a good idea for some cases (like farming an aggressively optimising but very slow compiler off to the cloud), but as the default case? No way. |
|