Comments (10)
缓存编译的委托这个考虑过,但是每次的参数都是动态传入的,做缓存委托的话,倒不如直接缓存调用结果咯,缓存的复用性不高,而且这样可能会造成缓存无限膨胀
from masuit.tools.
如果你有改进的办法,欢迎提交PR
from masuit.tools.
我去看了一眼,只是调用方法,这种情况下只调用一次时确实用反射更好一点。
如果改进,要先明确
- 要不要加缓存? 或者纠结的话可以考虑增加一个可选参数,默认是不缓存的。如果调用的少,调用者知道重复率高而缓存。但如果是框架使用,可能只调用一次,命中率低就不传了。
- 反射还是表达式编译?不加缓存的情况下,反射要好一点。原代码也是要反射去找方法体的
from masuit.tools.
缓存的复用性高不高看情况吧。
不过即使没有好的解决方案,建议也不要每次都调用Compile,这样的做法性能损耗实在太大,比直接反射还可怕。
对Compile生成的委托调用要比反射调用快,但Compile操作是极其损耗资源,毕竟Compile是编译代码操作,编译过程你懂的...如果不对生成的委托进行缓存,运行效率反而适得其反.
from masuit.tools.
目前想到了一种:把参数也作为表达式的参数进行传递,这样就能编译缓存了,我先改代码尝试一下
from masuit.tools.
缓存无限膨胀这情况是会有,但我觉得问题不大,因为ef,json.net,protobuf-net等知名库都大量这样使用
from masuit.tools.
我放弃了,仔细想想,能够创建实例那就可以直接调用其方法啊,这几个InvokeMethod也没有存在的必要了🤣🤣
from masuit.tools.
哈哈,ReflectionUtil里面的方法定位是动态调用,有存在必要的。日常开发可能用的少,但是写库或者通用逻辑的时候用的很多。虽然我没直接使用Masuit.Tools,但以后可能也会搬Masuit.Tools里得一些类自用,看到了ReflectionUtil里的实现有些问题,还是想提醒一下,哈哈。
from masuit.tools.
算了,先这样吧,以后想到好的法子了再改
from masuit.tools.
ReflectionUtil:我要见委座!我为Masuit.Tools立过功,我为Masuit.Tools留过血!
留着吧,框架类型、实例、什么都是动态的,是有可能用到的,可以标记为废弃呗? 这样项目更新时用到了,也不至于报错了
from masuit.tools.
Related Issues (20)
- 请求添加新功能:能否添加标志位枚举获取Description HOT 5
- 请求添加新功能:增加密码生成/弱密码检测功能 HOT 5
- [BUG] 检测mp4文件,会出现异常System.ArgumentOutOfRangeException: The Position must be within the length of the Stream: 2041547 (Parameter 'value') HOT 4
- [BUG]SaveFileAsync抛出异常ObjectDisposedException HOT 10
- [BUG]GetDaysOfMonth HOT 4
- RSA 使用私钥加密,公钥解密 HOT 1
- 请求添加新功能:bcrypt加密 HOT 2
- 没带缓存??就普通的内存缓存 HOT 3
- RSA签名验证是怎么用的? HOT 1
- 请求添加新功能:希望增加公式计算 HOT 3
- FTP判断当前目录下指定的子目录是否存在,这个代码好像不太对劲。 HOT 2
- Microsoft.EntityFrameworkCore.Relational限定可以修改为>=6.0.10吗 HOT 1
- [BUG].net版的日志写入存在问题 HOT 3
- 没错,反对996 人人有责 HOT 1
- [BUG] ini配置文件操作,没有ini文件生成 HOT 2
- 请求添加新功能:建议增加一个IsNotNullOrEmpty HOT 1
- 请求添加新功能:MaskEmailConverter等目前实现还是基于Newtonjson,感觉可以考虑增加对System.Text.json的支持了。 HOT 1
- [BUG] Masuit.Tools.Systems.Text.Json.MaskEmailConverter的wirterjson中的value方法少了null判断,有为空数据下直接异常了。 HOT 1
- [BUG]ToChineseMoney负数不生效 HOT 2
- 请问是否支持获取证书序列号 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from masuit.tools.