与同一计算机上的 Winforms 应用程序相比,相同的 C# 代码在 ASP.Net 应用程序中速度较慢
我们在 C# 中有一个函数,它使用 ICSharpCode SharpZipLib BZip2 解压缩方法来解压缩从数据库获取的一些 XML。我们注意到我们的两个网络服务器(Win 2K 和 Win 2003 Svr)上存在一个问题,即此代码需要很长时间才能执行,并导致这些服务器上的 CPU 利用率达到最大。我们已经隔离了代码并将其放入 Winforms 应用程序中进行测试,当在同一台计算机上的 winforms 应用程序中运行相同的代码时,代码运行得更快。这是使用相同的 SharpZipLib 程序集。
到目前为止我们不明白为什么代码在asp.net进程下运行速度这么慢。
有什么建议、想法吗?
提前致谢!
We have a function in C# that uses the ICSharpCode SharpZipLib BZip2 decompression method to uncompress some XML we get from a database. We have noticed an issue on two of our webservers (Win 2K and Win 2003 Svr) that this code takes a really long time to execute and causes the CPU utilization to max out on these servers. We have isolated the code and put it into a Winforms app for testing and when running this same code in the winforms app on the same machines the code runs much faster. This is with the same SharpZipLib assembly.
So far we are at a loss as to why the code runs so much slower under the asp.net process.
Any suggestions, ideas ?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用分析器。问题可能出在解压代码之外的某个地方。你、我和 SO 的其他人不会提供比一次分析器会话提供的更多信息。
Use a profiler. Problem might be somewhere outside of the decrompession code. You, I and the rest of the folks at SO won't give any more info than one profiler session will give.
您是否尝试过在 RedGate ANTS Performance Profiler 等分析器中查看代码以了解什么代码正在做什么?
ASP.NET 应用程序内部托管的代码与 WinForm 应用程序在完全不同的条件下运行。通过 IIS 工作进程加载时,您可能会遇到线程池问题。
您还可能遇到代码未在 ASP.NET 应用程序中预编译的问题。
话虽如此,通过 Profiler 运行您的应用程序将为您提供了解事物运行方式的最佳视图。
Have you tried watching the code in a Profiler like RedGate ANTS Performance Profiler to see what kind of things the code is doing?
Code hosted inside of an ASP.NET application is run under completely different conditions than a WinForm application. You could be running into ThreadPool issues when loading through the IIS worker process.
You could also be running into an issue where your code is not pre-compiled in your ASP.NET application.
All that being said, running your application through a Profiler is going to provide you with the best view into how things are working.
确保您正在创建一个 Web 项目并将其编译为发布版本。 (构建->配置管理器)
Make sure you are creating a web project and compile it for release build. (Build -> configuration manager)