String Comparision Performance Test
Comparasion done Replacing String.Compare with the below listed priorities.
Time Taken for comparing 100000000 Strings:
we can priorities as follows:
- a == b - the most efficient and visual style
- String.Equals(a,b) - equally efficient but pain to read from the code
- a.Equals(b) - not fast but more sane than the Object one
- Object.Equals(a,b) - very obscure way to compare strings
- String.Compare(a,b)==0 - bad way to check equality
Time Taken for comparing 100000000 Strings:
Time taken by == comparison 484 milliseconds
Time taken by CompareOrdinal method 537 milliseconds
Time taken by String.Compare method 18076 milliseconds
Time taken by String.Equals method 490 milliseconds
Comments
Post a Comment