为什么测试在 TeamCity 中运行比直接在 NUnit 中运行需要更长的时间?
我进行了一些 C# 性能测试,基本上运行两种不同的方法,并检查一种方法的运行速度是否比另一种方法快得多。
当我在 NUnit 本地运行它们时,其中一个测试的运行速度是另一个测试的十倍,因此我有一个 NUnit 测试,它使用 Stopwatch 来检查它是否至少是另一个测试的两倍(在回归的情况下)。但是当我在 TeamCity 中运行测试时,快速方法仅是慢速方法的 1.5 倍左右?我预计硬件差异会产生一些影响,但不会那么严重。可能是什么原因造成的?
I have some C# performance tests, basically running two different methods and checking that one runs much faster than the other.
When I run them locally in NUnit, one of the tests runs ten times as fast as the other, so I've got an NUnit test that uses Stopwatch
to check that it is at least twice as fast (in case of regression). But when I run the tests in TeamCity, the fast method is only about 1.5 times as fast as the slow one? I would expect hardware differences to have some effect, but not this much. What could be causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了回答我自己的问题,问题是在 TeamCity 中为测试构建打开了代码覆盖率,因此这样做的开销使两个方法运行时更加接近。希望这个答案将来对其他人有帮助。
To answer my own question, the problem turned out to be that code coverage was turned on for the test build in TeamCity, so the overhead of this brought the two method runtimes closer together. Hopefully this answer helps someone else in future.