1. 利用System.Diagnostics.StopWatch:

        static void Main(string[] args)
        {


            Stopwatch sw 
= new Stopwatch();

            sw.Start();
            
const int c_ExecutionCount = 1000000;

            
for (int i = 0; i < c_ExecutionCount; i++)
            {
                var obj 
= Factory<MyClass1>.Create(i);
                
//var obj = ReflectionFactory<MyClass1>(i);
            }

            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds 
+ "ms");
        }

相关文章: