What is faster?
Zap-o
Posts: 452
Is it better / faster to use IF statements or a Case statement? I intend on using many statements and for some reason I want to think that case is faster but not sure.
Comments
My guess would also be that the CASE command is faster especially when a significant number of conditions are checked. I would also imagine CASE would use less memory than IFs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
IF/ELSEIF is worst case: 8032 cycles best case: 1200 cycles
CASE is worst case: 6224 cycles best case: 1280 cycles
And the difference is 8 longs in memory.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!