Last active
June 13, 2018 16:41
-
-
Save ssougnez/1d3087dda07a8e77459dece5ca1fee4f 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
static void Main(string[] args) | |
{ | |
int iteration = 50000000; | |
UnsafeSquare(30); | |
Square(30); | |
var sw = new Stopwatch(); | |
sw.Start(); | |
for (int i = 0; i < iteration; ++i) | |
{ | |
UnsafeSquare(30); | |
} | |
sw.Stop(); | |
Console.WriteLine($"Unsafe: {sw.ElapsedMilliseconds}ms"); | |
sw.Restart(); | |
for (int i = 0; i < iteration; ++i) | |
{ | |
Square(30); | |
} | |
sw.Stop(); | |
Console.WriteLine($"Safe: {sw.ElapsedMilliseconds}ms"); | |
Console.ReadLine(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment