我升级了 ReSharper 并看到了一个我以前没有出现过的错误。我四处查看,但没有发现任何有关错误或它标记的潜在问题的信息。
** 编辑 **:正如下面所指出的,它实际上是“堆分配查看器”插件,而不是 ReSharper 本身将其标记为错误——尽管这不会改变问题本身。
Slow delegate creation: from interface 'IPluginHandler' method
这发生在插件处理程序订阅事件聚合器上的事件期间。
public void Subscribe(IPluginHandler subscriber)
{
Executing += subscriber.OnExecuting;
// -- additional subscriptions --
}
在上面的代码中,Executing
是一个事件,subscriber.OnExecuting
是该事件的适当事件处理程序。
需要明确的是,这是一个 ReSharper“软错误”,因为代码仍会按预期构建和运行。
所以我的问题是 JetBrains 的优秀人员为我提出的根本问题是什么,它的后果是什么。
谢谢
最佳答案
This JetBrains blog post在评论中有同样的问题。
那里的回复是这样说的:
Hi! This plugin also has one more internal feature: code inspection to show ‘slow’ (>10x slower) delegate instance creations for CLR x86 JIT. You can run this test (it creates delegates from various kinds of methods – virtual/interface/generic/etc) to see the difference in delegate creation performance.
Just as with allocations inspection – you shouldn’t care about this much until some performance snapshot in some hot path of your application shows long invocations of CLR internals. And just like with allocations – this inspections may (and will) produce false positives with new RuyJIT, for example.
请注意 linked test用箭头注释突出显示“缓慢”的委托(delegate)创建:<--
.
关于c# - 委托(delegate)创建缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26390745/