如何为.Net应用程序编写性能测试?
如何为.Net应用程序编写性能测试? nUnit 或任何其他测试框架是否为此提供了框架?
编辑:我必须衡量 WCF 服务的性能。
How to write Performance Test for .Net application? Does nUnit or any other Testing framework provides framework for this?
Edit: I have to measure performance of WCF Service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您对方法和算法的相对性能感兴趣,可以在 NUnit 测试中使用 System.Diagnostic.StopWatch 类来编写有关某些方法需要多长时间的断言。
在下面的简单示例中,primes 类是使用 [SetUp] 方法(未显示)实例化的,因为我感兴趣的是generatePrimes 方法花费了多长时间,而不是我的类的实例化,并且我正在编写一个断言该方法应该花费不到 5 秒的时间。这不是一个非常具有挑战性的断言,但希望可以作为如何做到这一点的示例。
If you are interested in relative performance of methods and algorithms, you can use the System.Diagnostic.StopWatch class in your NUnit tests to write assertions about how long certain methods take.
In the simple example below, the primes class is instantiated with a [SetUp] method (not shown), as I'm interested in how long the generatePrimes method is taking, not the instantiation of my class, and I'm writing an assertion that this method should take less than 5 seconds. This isn't a very challenging assertion, but hopefully serves as an example of how you could do this.
我发现 NTime 看起来很适合编写性能测试。
http://www.codeproject.com/kb/dotnet/NTime.aspx
I came across NTime which looks cool for writing performance Tests.
http://www.codeproject.com/kb/dotnet/NTime.aspx
NUnit 为您提供了一个单元测试框架:即在离散的“单元”中测试您的代码,以便您可以了解新的更改何时破坏了现有代码,或者您已经提供了一定级别的代码覆盖率。但它本身不提供性能测试。
为此,您将需要另一种类型的工具。如果您有网络应用程序,您可能想看看 The Grinder 或其他可以在这里找到的应用程序:
http ://www.opensourcetesting.org/performance.php
NUnit provides you with a framework for unit testing: i.e. testing your code in discrete "units" so that you can, amongst other things, be aware when new changes break existing code, or that you have provided a certain level of code coverage. But it does not provide performance testing per se.
For that, you will need another type of tool. If you have a webapp, you might like to take a look at The Grinder or others to be found here:
http://www.opensourcetesting.org/performance.php
VS Team System内置了性能测试模块。如果你有许可证的话值得探索。
VS Team System has built in performance testing modules. Worth exploring if u have licence for that.