Below is C# (Sharp) code compares performance for element existence in a large non-sequential set (only 312 elements) using in variety of typical code structures which are;
- one line IF (with ORs)
- multi-line Else Ifs
- Fall Through Case Statement
- Dictionary with Initialization Time
- Dictionary Lookup on Key, no init time
- Dictionary Lookup on Value, no init time
The live C# Code example below check's if a character is a vowel from a set of 312 Unicode vowels extending to Latin-Supplement Unicode code point.
Note: Under the hood C# compiler creates a dictionary for 6 or more case statements
https://youtu.be/1lnwO63LhRI?t=871
The results are rather surprising!
Note: Under the hood C# compiler creates a dictionary for 6 or more case statements
https://youtu.be/1lnwO63LhRI?t=871
The results are rather surprising!
No comments:
Post a Comment