Microsoft PolicyInjection 创建速度太慢
由于某种原因,我们的项目正在使用 PolicyInjection(来自 Microsoft EnterpriseLibrary)。 问题是,PolicyInjection.Create(params) 大约需要 30 毫秒。这实在是太多了,因为对于单个请求它被调用超过 100 次,这总结起来就是不可接受的性能损失。 这个问题有什么解决办法吗?我们正在使用 EnterpriseLibary 4.1
Our project is using PolicyInjection (from Microsoft EnterpriseLibrary) for some reason.
Problem is, that PolicyInjection.Create(params) takes about 30 ms. This is WAY too much since it is called over 100 times for single request which summs up in unaccapetable performance hit.
Is there any solution to this problem? We are using EnterpriseLibary 4.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。因此,经过大量调查后,我得出的结论是,PolicyInjection 确实非常慢,永远不应该在项目中使用!我们将切换到 PostSharp 或干脆摆脱 PI。 PI在后台使用Unity来构建代理类。这是一个极其缓慢的过程。没有缓存,所以速度很慢很慢。 PI Create 很容易花费 30 毫秒甚至更多的时间。使用它的唯一方法是,如果您非常确定它不会被调用超过几次(但即使 30 次调用也会在 1 秒内结束)。
Ok. So after a lot of investigation I came to conclusion that PolicyInjection simply really is very slow and should never be used in projects! We are going to switch over to PostSharp or simply get rid of PI. PI uses Unity in background for building proxy class. This is incredibly slow process. There are no caches so it is slow slow slow. PI Create can easily take 30 and more miliseconds. Only way to use it is if you are very sure that it won't get called more than few times (but even 30 calls will end up in 1 second).