/home/karthik/blog

Switch Case Vs If else performance

Posted in Programming by Karthik Murugesan on December 19, 2006

Most people know that performance of switch/case is better than an if/else statement, if the case values are narrowed. But many doesnt know the reason why switch/case statement performance is better. I came across this tutorial which discusses on the assembly view of switch/case for different scenarios like narrowed case values, wides case values etc and how it differs from the if/else statement. From this, its clear that the Switch/case performance is better for narrowed case values.

Even though the discussion is specific to 68000, the concept remains the same across processors/compilers.

check it out @ http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation3.htm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: