Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/1d3087dda07a8e77459dece5ca1fee4f to your computer and use it in GitHub Desktop.
Save ssougnez/1d3087dda07a8e77459dece5ca1fee4f to your computer and use it in GitHub Desktop.
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