Re: Need help with efficiency NXC code
Posted: 20 Aug 2011, 05:37
muntoo, ahh I see, that makes it easier. Any idea for why this limitation was made btw?
About the profiling results,
It definitively needs another run. Almost half of the spend time is used outside the profiled sections, we could be overlooking something important. I usually time large sections first covering the whole program and then dig down into the interesting parts, timing those in more detail.
Anyway, from these results the first part outside the ******************s is of interest in my opinion. Tile() is of cause the biggest player, but Jump(), MoveRight(), Down() and CheckVargs() ends up being 15% combined never the less. Most of them are related to player movement, perhaps you can improve performance by combining them?
John,
My proposal is to ignore the boolean value during the evaluation and calculate it afterwards. I argue thatwill work exactly likeI also argue that this approach is more efficient than calculating the boolean value during the evaluation when it needs to be short-circuited.
Feel free to prove me wrong.
It also might be worth to do something like this instead:Some speed-tests might cast light upon that.
I cannot see why it should be that hard to implement. There should be two functions, one that generates the corresponding code when a boolean expression is needed for a conditional jump and another one which generates the code for when the boolean value is needed from a boolean expression. (The second function can be easily implemented by using the first in a if-like structure shown above.)
If the boolean expression belongs to a if, for, while or do-while structure, use the first function. Otherwise use the second. Is there anything which makes this hard to do with the current compiler?
About the profiling results,
It definitively needs another run. Almost half of the spend time is used outside the profiled sections, we could be overlooking something important. I usually time large sections first covering the whole program and then dig down into the interesting parts, timing those in more detail.
Anyway, from these results the first part outside the ******************s is of interest in my opinion. Tile() is of cause the biggest player, but Jump(), MoveRight(), Down() and CheckVargs() ends up being 15% combined never the less. Most of them are related to player movement, perhaps you can improve performance by combining them?
John,
My proposal is to ignore the boolean value during the evaluation and calculate it afterwards. I argue that
Code: Select all
__D0main = b1 && b2; //Or any other boolean expression
Code: Select all
if( b1 && b2 )
__D0main = true;
else
__D0main = false;
Feel free to prove me wrong.
It also might be worth to do something like this instead:
Code: Select all
__D0main = false;
if( expression )
__D0main = true:
I cannot see why it should be that hard to implement. There should be two functions, one that generates the corresponding code when a boolean expression is needed for a conditional jump and another one which generates the code for when the boolean value is needed from a boolean expression. (The second function can be easily implemented by using the first in a if-like structure shown above.)
If the boolean expression belongs to a if, for, while or do-while structure, use the first function. Otherwise use the second. Is there anything which makes this hard to do with the current compiler?