I was looking at what GCC does with the -O3(what I make sure that all of my code compiles with) and I was wondering how much usefullness of unswitching the loops is in an interpreted language. I was was wondering if it'd be worth it for code that is "production" ready, such as when you use google's closure compiler, since it'd speed it up a bit but not a lot I imagine. Well anyway how much benefit does this truly produce? I imagine that it is x checks for y loops. Where x is the number of if else ifs, or case switches, and y is the number of loops. So it's x*y. But how much is it worth it when you're using an interpreted language?
I'm asking it in a completely theoretical way, as I was just wondering about it, I doubt it's much of anything, and might even make it backwards since it has to read every character when it's running it.
OK here's what I'm talking about with the unswitching of the loops.
Also interpreted is what I mean by any language that is compiled at run-time and/or is ran through a VM, examples are; PHP, JavaScript, BASH, Ruby, Perl, etc.
I don't know if I worded it right above. But that's what I was meaning, in those languages wherein you have to read the input byte by byte and then transform it into something that you can use. I also know there are other things you can do to speed it up, but that's the simplest way that I can think of to explain it.
normal loop.
for(i=0;i<10;++i){
if(something==3){
do_something;
}
else{
do_something_else;
}
unswitched loop(according to what I've been able to gather from the clang documentation(gcc's crap).
if(something=3){
for(i=0;i<10;++i){
do_something;
}
else{
for(i=0;i<10;++i){
do_something_else
}
}
The code above is supposedly what they do.