利用dynamic来提供动态方法的性能
前段时间做了一个worklist的项目,有部分是利用xml配置DICOM的tag,然后根据xml把DICOM的Dataset转为实体类,或者把实体类转为Dataset。
Avoid using Type.InvokeMember to call late-bound methods Type.InvokeMember is the slowest way to invoke a member via reflection. If your scenario doesn't involve COM interop invocation (something which Type.InvokeMember makes easier), consider other alternatives for setting up calls to members obtained through late-bound methods.
Avoid case-insensitive member lookups When calling both the plural and non-plural GetXX APIs, avoid specifying BindingFlags.IgnoreCase as a binding flag argument as it has a significant invocation and working set costs. Metadata is case sensitive and to perform an "ignore case" operation, reflection needs to obtain the metadata string names for all members of a type and then do a case-insensitive comparison. In addition, due to the design of the reflection cache, a second MemberInfo cache is created for the case-insensitive members, which basically doubles an application's working set.
Use BindingFlags.ExactMatch whenever possible Specify this BindingFlag when calling MethodBase.Invoke if you know that the types of the arguments you are passing exactly match the types of the method's parameters. It will allow reflection to go down an optimized, more efficient code path that does not perform argument type-coercion. If the argument types don't match the method's parameter types, an exception will be thrown.
Call the non-plural GetXX method if you know the name of the instance you care about (.NET Framework 2.0 only) The MemberInfo cache is lazily populated in the .NET Framework 2.0, which means lower working set cost, and less time to retrieve the method. If you know the name of the particular method you want to obtain, use the non-plural GetXX method.
利用dynamic来提供动态方法的性能的更多相关文章
- Flask06 地址约定、利用falsk提供的方法渲染模板
		
1 访问地址约定 在访问路径的末尾是否需要加 / -> 可以加,也可以不加 前端的访问路径必须和后端的路径完全匹配才能够访问成功,如果我们在后台的路径都是以 / 结尾,但是我们的访问路径是没有以 ...
 - 2018.12.15 struts.xml 一般配置文件写法  &&  配置动态方法
		
struts.xml 原始配置文件 配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE s ...
 - Dynamic Method Binding in Delphi  动态方法绑定
		
Dynamic Method Binding in Delphi 动态方法绑定 https://docs.dataabstract.com/Delphi/AdvancedTopics/Dynamic ...
 - 深入浅出Cocoa之消息(二)-详解动态方法决议(Dynamic Method Resolution) 【转】
		
序言 如果我们在 Objective C 中向一个对象发送它无法处理的消息,会出现什么情况呢?根据前文<深入浅出Cocoa之消息>的介绍,我们知道发送消息是通过 objc_send(id, ...
 - 使用 jQuery 基本选择器获取页面元素,然后利用 jQuery 对象的 css() 方法动态设置 <span> 和 <a> 标签的样式
		
查看本章节 查看作业目录 需求说明: 使用 jQuery 基本选择器获取页面元素,然后利用 jQuery 对象的 css() 方法动态设置 <span> 和 <a> 标签的样式 ...
 - 多态,动态方法调度(dynamic method dispatch)?
		
8.多态Polymorphism,向上转型Upcasting,动态方法调度(dynamic method dispatch) 什么叫多态?简言之,马 克 - t o - w i n:就是父类引用指向子 ...
 - [2017-08-25]100行CSharp代码利用dynamic写个DSL(特定领域语言)
		
最近看<CLR via C#(第4版)> 读到第五章末尾dynamic基元类型时,看了下作者的一个利用dynamic动态调用string类型的Contains方法(静态方法)的实现,突然发 ...
 - 利用dynamic解决匿名对象不能赋值的问题
		
原文:利用dynamic解决匿名对象不能赋值的问题 关于匿名对象 匿名对象是.Net Framework 3.0提供的新类型,例如: }; 就是一个匿名类,搭配Linq,可以很灵活的在代码中组合数据, ...
 - 第三章Struts2 Action中动态方法调用、通配符的使用
		
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
 
随机推荐
- 九度OJ 1205:N阶楼梯上楼问题 (斐波那契数列)
			
时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3739 解决:1470 题目描述: N阶楼梯上楼问题:一次可以走两阶或一阶,问有多少种上楼方式.(要求采用非递归) 输入: 输入包括一个整 ...
 - phpstorm10激活方法
			
选择 license server ---> http://idea.lanyus.com/ (末尾的斜杠不能漏了!) 2016-7-5更新 上面的注册方法再试时,已被封杀 2017-9-1 ...
 - centos修改mysql密码或者进入mysql后解决Access denied for user ''@'localhost' to database 'mysql错误
			
原因是MySQL的密码有问题 用mysql匿名用户可以进入数据库,但是看不见mysql数据库. 解决办法:具体操作步骤:关闭mysql:# service mysqld stop然后:# mysqld ...
 - Bootstrap第2天
			
Bootstrap第2天 解决IE低版本不支持HTML5元素的方法 CSS全局样式--栅格系统 1.栅格系统介绍 Bootstrap提供了一套响应式.移动设备优先的流式的栅格系统. B ...
 - Windows平台下搭建Git服务器的图文教程(转发)
			
Git没有客户端服务器端的概念,但是要共享Git仓库,就需要用到SSH协议(FTP , HTTPS , SFTP等协议也能实现Git共享,此文档不讨论),但是SSH有客户端服务器端,所以在window ...
 - Java并发之ArrayBlockingQueue
			
ArrayBlockingQueue是一个由数组支持的有界阻塞队列.此队列按 FIFO(先进先出)原则对元素进行排序.队列的头部是在队列中存在时间最长的元素.队列的尾部是在队列中存在时间最短的元素.新 ...
 - python基础13 ---函数模块3(正则表达式)
			
正则表达式 一.正则表达式的本质 1.正则表达式的本质(或 RE)是一种小型的.高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现.正则表达式模式被编译成一系列的 ...
 - ubuntu14.04下svn版本管理系统的安装及常用命令的使用整理
			
ubuntu14.04下安装svn$sudo apt-get install subversion 执行这一步就安装完成了,在ubuntu先安装很方便 安装完成后,创建版本库目录,由于是本地环境,就在 ...
 - [原创]java WEB学习笔记27:深入理解面向接口编程
			
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
 - GAN基础
			
Generative Adversarial Networks GAN框架 GAN框架是有两个对象(discriminator,generator)的对抗游戏.generator是一个生成器, ...