c#测试反射性能示例
Activator.CreateInstance和AssemblyCreateInstance性能测试
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Diagnostics;
usingSystem.Linq;
usingSystem.Security.Cryptography;
usingSystem.Text;
usingHelloWorld.ServiceReference1;
usingSystem.Globalization;
usingSystem.Reflection;
usingInterface;
namespaceHelloWorld
{
classProgram
{
staticvoidMain(string[]args)
{
Stopwatchs=newStopwatch();
Assemblya=Assembly.GetExecutingAssembly();
//foreach(varstina.GetExportedTypes())
//{
// Console.WriteLine(st.Name);
//}
s.Reset();
s.Start();
Typet=a.GetType("HelloWorld.Test1");
Interface1i2=(Interface1)(Activator.CreateInstance(t));
Console.WriteLine((i2.Add(1,2)));
s.Stop();
Console.WriteLine(s.Elapsed);
s.Reset();
s.Start();
Interface1i=(Interface1)a.CreateInstance("HelloWorld.Test1");
Console.WriteLine((i.Add(1,2)));
s.Stop();
Console.WriteLine(s.Elapsed);
}
}
publicclassTest1:Interface1
{
publicintAdd(inta,intb)
{
returna+b;
}
}
publicinterfaceInterface1
{
intAdd(inta,intb);
}
}
相关文章
- transactionscope mysql_c# – 嵌套的TransactionScope在测试中失败
- c# mysql executenonquery_C#与数据库访问技术总结(八)之ExecuteNonQuery方法
- c#面试题抽象类和接口的区别-金三银四面试:C#程序员经常遇到的30道基础面试题,想你所想
- 自动化测试如此容易!多语言自动化测试框架 Selenium 编程(C#篇)
- C#操作注册表的方法
- c#引用类型构造器
- C#各种集合操作的性能总结
- 在C#中对TCP客户端的状态封装详解
- c#测试本机sql运算速度的代码示例分享
- 支持多类型数据库的c#数据库模型示例
- c#创建windows服务入门教程实例
- C#检测是否有危险字符的SQL字符串过滤方法
- C#读取二进制文件方法分析