最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

c#測(cè)試反射性能示例

 更新時(shí)間:2014年03月27日 10:16:17   作者:  
這篇文章主要介紹了c#測(cè)試反射性能示例,Activator.CreateInstance和AssemblyCreateInstance性能測(cè)試,需要的朋友可以參考下

Activator.CreateInstance和AssemblyCreateInstance性能測(cè)試

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using HelloWorld.ServiceReference1;
using System.Globalization;
using System.Reflection;
using Interface;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Stopwatch s = new Stopwatch();
            Assembly a = Assembly.GetExecutingAssembly();

            //foreach (var st in a.GetExportedTypes())
            //{
            //    Console.WriteLine(st.Name);
            //}

            s.Reset();
            s.Start();
            Type t = a.GetType("HelloWorld.Test1");
            Interface1 i2 = (Interface1)(Activator.CreateInstance(t));
            Console.WriteLine((i2.Add(1, 2)));
            s.Stop();
            Console.WriteLine(s.Elapsed);


            s.Reset();
            s.Start();
            Interface1 i = (Interface1)a.CreateInstance("HelloWorld.Test1");
            Console.WriteLine((i.Add(1, 2)));
            s.Stop();
            Console.WriteLine(s.Elapsed);

        }
    }
    public class Test1 : Interface1
    {
        public int Add(int a, int b)
        {
            return a + b;
        }
    }
    public interface Interface1
    {
        int Add(int a, int b);
    }
}

相關(guān)文章

最新評(píng)論

清丰县| 容城县| 沾化县| 化德县| 志丹县| 乳源| 高清| 外汇| 台山市| 宕昌县| 洛隆县| 茌平县| 西和县| 赣榆县| 高雄县| 天门市| 灵石县| 望江县| 彩票| 同江市| 宣汉县| 措勤县| 肇州县| 高青县| 乐安县| 松阳县| 建宁县| 大连市| 灵丘县| 白河县| 红河县| 长泰县| 康保县| 新密市| 潢川县| 镇坪县| 肥城市| 财经| 广水市| 灵川县| 南华县|