当前位置: 首页 > news >正文

网站如何备案 附备案流程图中职学校专业建设规划

网站如何备案 附备案流程图,中职学校专业建设规划,wordpress discuz,网站全站搜索代码一说到反射#xff0c;很多人都想到了性能#xff0c;更有甚者直接说“慎用反射#xff0c;遗患无穷”#xff0c;“用反射#xff0c;感觉怎么像是退步啊#xff5e;”#xff0c;看到这种言论#xff0c;直接把反射妖魔化了#xff0c;如果这种言论长此以往#xf…  一说到反射很多人都想到了性能更有甚者直接说“慎用反射遗患无穷”“用反射感觉怎么像是退步啊”看到这种言论直接把反射妖魔化了如果这种言论长此以往势必会对很多对反射初学者造成负面影响。反射是一把双刃剑看你怎样使用了下面我就用代码说话。 class TestEntity { }1. 手工创建TestEntity  [TestInfo(Category Class.Constructor, Name Direct)]class DirectInvokeMode:IRunable {public void Run() {new TestEntity(); } }      2. 反射创建TestEntity  [TestInfo(Category Class.Constructor, Name Reflect)]class ReflectInvokeMode : IRunable {public void Run() { Activator.CreateInstance(typeof(TestEntity)); } }   3. 泛型反射创建TestEntity [TestInfo(Category Class.Constructor, Name GenericReflect)]class GenericReflectInvokeMode : IRunable {public void Run() { Activator.CreateInstanceTestEntity(); } }   4. Generic 直接创建 [TestInfo(Category Class.Constructor, Name Generic Create)]class GenericCreateInvokeMode : IRunable {public void Run() { CreateTestEntity(); }static T CreateT() where T : new() {return new T(); } } 5. Emit创建 [TestInfo(Category Class.Constructor, Name Emit)]class EmitInvokeMode : IRunable {static readonly ConstructorHandler Ctor typeof(TestEntity).GetConstructor(Type.EmptyTypes).GetCreator();public void Run() { Ctor(); } }   6. 不缓存Emit的创建 [TestInfo(Category Class.Constructor, Name NoCacheEmit)]class NoCacheEmitInvokeMode : IRunable {public void Run() {typeof(TestEntity).GetConstructor(Type.EmptyTypes).GetCreator()(); } }   测试程序执行10万次创建Class对象 foreach (var item in Mappers) CodeTimer.Time(item.Metadata.Category - item.Metadata.Name, 100000, () item.Value.Run()); 输出结果 ------ Test started: Assembly: NLite.Test.dll ------Class.Constructor-Direct Time Elapsed: 5ms CPU Cycles: 0 Gen 0: 1 Gen 1: 0 Gen 2: 0Class.Constructor-Reflect Time Elapsed: 320ms CPU Cycles: 2,968,750 Gen 0: 1 Gen 1: 0 Gen 2: 0Class.Constructor-GenericReflect Time Elapsed: 147ms CPU Cycles: 1,250,000 Gen 0: 1 Gen 1: 0 Gen 2: 0Class.Constructor-Generic Create Time Elapsed: 159ms CPU Cycles: 1,406,250 Gen 0: 1 Gen 1: 0 Gen 2: 0Class.Constructor-Emit Time Elapsed: 6ms CPU Cycles: 0 Gen 0: 2 Gen 1: 0 Gen 2: 0Class.Constructor-NoCacheEmit Time Elapsed: 12,786ms CPU Cycles: 119,218,750 Gen 0: 162 Gen 1: 81 Gen 2: 01 passed, 0 failed, 0 skipped, took 67.77 seconds (NUnit 2.5.5).   性能比较结果应该是一目了然了       附上源代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; using System.Reflection; using NLite.Reflection;namespace NLite.Test.Reflection {[Contract]public interface IRunable{void Run();}//测试器元数据public interface ITestInfo{//目录string Category { get; }//名称string Name { get; }}//映射器元数据注解[AttributeUsage(AttributeTargets.Class, AllowMultiple false)][MetadataAttributeAttribute]public class TestInfoAttribute : ComponentAttribute{public string Category { get; set; }public string Name { get; set; }}[TestFixture]public class SpecBase{public SpecBase(){}[SetUp]public void SetUp(){Given();When();}public virtual void Given() { }public virtual void When(){}[Test]public void Test(){}}public abstract class PerformanceSpecBase : SpecBase{[InjectMany]protected LazyIRunable, ITestInfo[] Mappers;protected abstract void RegisterComponents();public virtual int Times{get { return 100000; }}public override void Given(){RegisterComponents();ServiceRegistry.Compose(this);}public override void When(){for (int i 0; i 3; i){foreach (var item in Mappers)CodeTimer.Time(item.Metadata.Category - item.Metadata.Name, Times, () item.Value.Run());}}}public class InvokeConstructorPerformanceSpec : PerformanceSpecBase{class TestEntity { }protected override void RegisterComponents(){ServiceRegistry.RegisterDirectInvokeMode().RegisterReflectInvokeMode().RegisterGenericReflectInvokeMode().Register GenericCreateInvokeMode().RegisterEmitInvokeMode().Register NoCacheEmitInvokeMode().Register GenericReflectInvokeMode2();}[TestInfo(Category Class.Constructor, Name Direct)]class DirectInvokeMode:IRunable{public void Run(){new TestEntity();}}[TestInfo(Category Class.Constructor, Name Reflect)]class ReflectInvokeMode : IRunable{public void Run(){Activator.CreateInstance(typeof(TestEntity));}}[TestInfo(Category Class.Constructor, Name GenericReflect)]class GenericReflectInvokeMode : IRunable{public void Run(){Activator.CreateInstanceTestEntity();}}[TestInfo(Category Class.Constructor, Name Reflect-Reflect)]class GenericReflectInvokeMode2 : IRunable{static readonly MethodInfo CreateMethod typeof(Activator).GetMethod(CreateInstance, Type.EmptyTypes).MakeGenericMethod(typeof(TestEntity));public void Run(){CreateMethod.Invoke(null,null);}}[TestInfo(Category Class.Constructor, Name Generic Create)]class GenericCreateInvokeMode : IRunable{public void Run(){CreateTestEntity();}static T CreateT() where T : new(){return new T();}}[TestInfo(Category Class.Constructor, Name Emit)]class EmitInvokeMode : IRunable{static readonly ConstructorHandler Ctor typeof(TestEntity).GetConstructor(Type.EmptyTypes).GetCreator();public void Run(){Ctor();}}[TestInfo(Category Class.Constructor, Name NoCacheEmit)]class NoCacheEmitInvokeMode : IRunable{public void Run(){typeof(TestEntity).GetConstructor(Type.EmptyTypes).GetCreator()();}}}}最后给大家一个思考题Struct 创建性能大比拼的结果是怎样的注意Struct是值类型Class是引用类型值类型是分配在栈上的引用类型是分配在堆上的转载于:https://www.cnblogs.com/netcasewqs/archive/2011/04/18/2019999.html
http://www.zqtcl.cn/news/166719/

相关文章:

  • 海尔电子商务网站建设预算灵台县门户网
  • 四川网站建设设计公司排名开发公司与建筑公司合作协议
  • 江西智能网站建设嘉定注册公司
  • 海口网站建设联系方式十大免费软文推广平台
  • 石碣镇做网站帮别人做网站开价
  • 站长 网站ip客户都不愿意做网站
  • 网站开发和软件开发哪个难网站备案账号
  • 2昌平区网站建设安徽盛绿建设网站
  • 商务网站建设目的天津建设网站需要的费用
  • flash 网站头部wordpress支持大文件上传
  • 网站开发方式的选择凡客设计
  • 常德建设网站如何查询某个网站的设计公司
  • wordpress 仿站教程学校ui设计培训
  • 南昌模板建站定制网站合肥瑶海区网站建设价格
  • 奥尔马手表官方网站导出wordpress文章
  • 网站栏目内容和功能手机网站建设 如何获得更好的排名
  • 网站运营推广难做常德网警
  • 北滘网站建设公司在百度上做网站怎么做
  • 合肥网站建设 毅耘园林设计网站大全
  • 免费备案网站空间爱营销app
  • 郑州网站建设公网站建设需要步骤
  • 源创派网站建设做软件赚钱的网站有哪些
  • 中英文网站建设公司推广引流
  • 网站改域名百度热词指数
  • 网站开发工程师工作内容网站源码是用什么做的
  • 做网站优化费用免费的视频网站如何赚钱
  • 如何制作一个好网站中国建设银行网站暑假工报名
  • 阿里巴巴做网站找谁网站建设需要ui吗
  • 如何评价伊利集团网站建设长沙专业竞价优化首选
  • 网站建设费用标准做网站怎么盈利