简体   繁体   English

.NET方法(.dll)和反映版本之间的性能差异

[英]Performance difference between .NET method (in .dll) and reflected version

I have been attempting to optimize a JavaScript encode function (in C#) to improve its performance (in an overall attempt of improving the performance of an enterprise web application). 我一直在尝试优化JavaScript编码功能(在C#中)以提高其性能(总体上是为了提高企业Web应用程序的性能)。 We attempted to use the .NET HttpUtility.JavaScriptStringEncode but it does not encode the way our data layer is anticipating (and changing the data layer is not on the table). 我们尝试使用.NET HttpUtility.JavaScriptStringEncode但它没有编码我们的数据层预期的方式(并且更改数据层不在表上)。

Using the RedGate profiler tool I determined the best performance of our function is around 8% of the total page load. 使用RedGate分析器工具,我确定我们的功能的最佳性能约占总页面负载的8%。 When I use the .NET function (on a page that accepts it), it comes in at around .08% of total page load. 当我使用.NET函数(在接受它的页面上)时,它占总页面加载的大约.08%。 We reflected the .NET function to see what sorcery they were working and when I copied the reflected code into the function and ran it directly, it performed at around 10%. 我们反映了.NET函数,看看他们正在使用什么样的魔法,当我将反射的代码复制到函数中并直接运行时,它的执行率大约为10%。

I'm curious as to why. 我很好奇为什么。 How is the .NET function prepared differently to award such a performance increase? 如何通过不同的方式准备.NET功能以奖励这样的性能提升?

I apologize in advance but I cannot paste up the function that we are using, but I don't think that should impact answering the question. 我提前道歉,但我不能粘贴我们正在使用的功能,但我认为这不会影响回答问题。

Can you compare the IL code produced after you paste the reflected code into your library with the IL code present in the .NET library? 您可以将将反射的代码粘贴到库中的IL代码与.NET库中的IL代码进行比较吗? The compiler switch being used to compile can cause such differences. 用于编译的编译器开关可能会导致此类差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM