Created
November 7, 2019 18:25
-
-
Save kshyju/7b37b952aaa23a4c9e8d751f4ce6a775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MemoryDiagnoser] | |
public class LastBenchmarks | |
{ | |
string[] segments = "abc/xyz".Split('/'); | |
[Benchmark] | |
public string LastitemUsingLINQ() | |
{ | |
return segments.Last(); | |
} | |
[Benchmark] | |
public string LastUsingArrayIndex() | |
{ | |
var lastSegmentIndex = segments.Length - 1; | |
return segments[lastSegmentIndex]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment