От: | nikov | http://www.linkedin.com/in/nikov | |
Дата: | 14.11.07 16:41 | ||
Оценка: | 85 (13) |
using System;
using System.Diagnostics;
class Program
{
const int ITERATION_COUNT = 100000;
static void Main()
{
TestReflection();
TestGenericNew<Exception>();
}
static void TestReflection()
{
Stopwatch s = new Stopwatch();
s.Start();
for (int i = 0; i < ITERATION_COUNT; i++)
{
Exception ex = (Exception) Activator.CreateInstance(typeof(Exception));
}
s.Stop();
Console.WriteLine(s.ElapsedTicks);
}
static void TestGenericNew<T>() where T : Exception, new()
{
Stopwatch s = new Stopwatch();
s.Start();
for (int i = 0; i < ITERATION_COUNT; i++)
{
Exception ex = new T();
}
s.Stop();
Console.WriteLine(s.ElapsedTicks);
}
}
100040189
762155730