Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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