由于JIT_MethodAccessCheck,编译的表达式树变慢 [英] Compiled Expression Tree slow due to JIT_MethodAccessCheck

查看:82
本文介绍了由于JIT_MethodAccessCheck,编译的表达式树变慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用编译的表达式树来动态生成代码;一些仅在运行时可供我们使用的信息使我们(理论上)可以编写更简单,更快的代码. 在许多情况下,我们确实可以提高性能.

We're using compiled Expression Trees to generate code dynamically; some information only available to us at runtime enables us to (in theory) write simpler, faster code. We do get a performance boost in many cases.

但是,在某些情况下,我们会降低性能.在这种情况下,Visual Studio Profiler显示性能差异是由于此方法引起的(在静态编译的代码中根本没有出现)

However, in some cases we get a performance hit. In such cases, the Visual Studio Profiler shows that the difference in performance is due to this method (which doesn't show up at all in statically compiled code)

JIT_MethodAccessCheck

此方法有什么作用? (Google对此不多说). 我可以以某种方式对其进行优化吗?

What does this method do? (Google doesn't have much to say about it). Can I optimize it away somehow?

推荐答案

在此答案中使用代码片段来编译表达式树,从而摆脱了对方法边界的检查:

Use the code snippet in this answer to compile expression trees instead, it gets rid of the checks across method boundaries:

为什么JIT_MethodAccessAllowedBySecurity需要这么多时间? /a>

Why is JIT_MethodAccessAllowedBySecurity taking so much time?

这篇关于由于JIT_MethodAccessCheck,编译的表达式树变慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆