cab之性能优化——使用ObGen和CabGen
2008-01-15 21:40
357 查看
方法:
You just run both tools on your shell and module assemblies, by passing the assembly file path to the tool as the first command line argument. That will generate "assembly.cabgen.dll" and "assembly.obgen.dll". You just need to deploy these alongside your exe/dlls and you should inmediately see the performance improvement.
原理:
By default, the tools will leave a .cs file alongside the generated assembly that contains the source emitted for it. You can inspect that to see how everything works.
Basically the ObGen tool generates a class implementing IPolicyProvider, which is probed by name. If it exists, it is used to retrieve the policies that apply to the object being built, instead of reflecting on the attributes of the type at run-time. Saving reflection is only one part, though. The other is that by avoiding reflection, we can also pass policies that implement strong-typed policy behavior, such as a custom creation policy that will do new MyObject() instead of Activator.CreateInstance.
The combined reflection + strong-typing proved to be a huge perf. boost on the device.
You just run both tools on your shell and module assemblies, by passing the assembly file path to the tool as the first command line argument. That will generate "assembly.cabgen.dll" and "assembly.obgen.dll". You just need to deploy these alongside your exe/dlls and you should inmediately see the performance improvement.
原理:
By default, the tools will leave a .cs file alongside the generated assembly that contains the source emitted for it. You can inspect that to see how everything works.
Basically the ObGen tool generates a class implementing IPolicyProvider, which is probed by name. If it exists, it is used to retrieve the policies that apply to the object being built, instead of reflecting on the attributes of the type at run-time. Saving reflection is only one part, though. The other is that by avoiding reflection, we can also pass policies that implement strong-typed policy behavior, such as a custom creation policy that will do new MyObject() instead of Activator.CreateInstance.
The combined reflection + strong-typing proved to be a huge perf. boost on the device.
相关文章推荐
- mongodb之使用explain和hint性能分析和优化
- Android性能优化-缓存的使用
- MySQL性能优化的21个最佳实践 和 mysql使用索引
- 性能优化:使用ramlog将日志文件转移到内存中
- Unity3D中使用Profiler精确定位性能热点的优化技巧
- Android 性能优化:使用 Lint 优化代码、去除多余资源
- SqlServer性能检测和优化工具使用详细
- Android 性能优化之使用线程池处理异步任务
- Entity FrameWork 中使用Lambda访问数据库性能优化
- oracle 性能优化操作十七: 使用位图索引
- 总结使用Unity 3D优化游戏运行性能的经验
- 使用protostuff自定义编解码器优化springcloud-feign性能
- iOS性能优化之内存管理:Analyze、Leaks、Allocations的使用和案例代码
- Entity FrameWork 中使用Expression<Func<T,true>>访问数据库性能优化
- iOS性能优化:Instruments使用实战
- MySQL索引使用方法和性能优化
- 性能优化:使用SparseArray代替HashMap<Integer,Object>
- babel-polyfill使用与性能优化
- [MySQL优化] -- 如何使用SQL Profiler 性能分析器
- [JavaScript]使用document.createDocumentFragment优化性能