using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 10000; i++)
{
box();
}
sw.Stop();
Console.WriteLine("Box = " + sw.Elapsed.ToString());
Stopwatch sw1 = new Stopwatch();
sw1.Start();
for (int j = 0; j < 10000; j++)
{
unbox();
}
sw1.Stop();
Console.WriteLine("Box = " + sw1.Elapsed.ToString());
Console.ReadLine();
}
private static void box()
{
int i = 123;
object j = i;
}
private static void unbox()
{
int i = 123;
int j = i;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 10000; i++)
{
box();
}
sw.Stop();
Console.WriteLine("Box = " + sw.Elapsed.ToString());
Stopwatch sw1 = new Stopwatch();
sw1.Start();
for (int j = 0; j < 10000; j++)
{
unbox();
}
sw1.Stop();
Console.WriteLine("Box = " + sw1.Elapsed.ToString());
Console.ReadLine();
}
private static void box()
{
int i = 123;
object j = i;
}
private static void unbox()
{
int i = 123;
int j = i;
}
}
}