性能做TDD测试时的最佳做法? [英] Performance testing best practices when doing TDD?

查看:239
本文介绍了性能做TDD测试时的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,该项目是在一些性能调优的严重的需要。

I'm working on a project which is in serious need of some performance tuning.

我如何写一个测试,如果我的优化不提高程序的速度失败?

How do I write a test that fails if my optimizations do not in improve the speed of the program?

要详细一点:

问题是不是发现优化哪些部分。我可以使用各种分析和基准测试工具为。

The problem is not discovering which parts to optimize. I can use various profiling and benchmarking tools for that.

问题是使用的自动的测试记录一个特定的优化的确有预期的效果。这也将是非常可取的,如果我可以使用测试套件,后来发现可能的性能下降。

The problem is using automated tests to document that a specific optimization did indeed have the intended effect. It would also be highly desirable if I could use the test suite to discover possible performance regressions later on.

我想我可以只运行我的分析工具得到一些值,然后断言,我的优化code产生更好的价值。与明显的问题,但是,是基准值不是硬值。他们与当地的环境而异。

I suppose I could just run my profiling tools to get some values and then assert that my optimized code produces better values. The obvious problem with that, however, is that benchmarking values are not hard values. They vary with the local environment.

那么,答案始终使用同一台机器做这种集成测试?如果是这样,你仍然要允许在结果会模糊性,因为即使在相同的硬件基准测试结果可能会有所不同。那么,如何考虑到这一点?

So, is the answer to always use the same machine to do this kind of integration testing? If so, you would still have to allow for some fuzziness in the results, since even on the same hardware benchmarking results can vary. How then to take this into account?

或者,也许答案是保留旧版本的程序前后对比效果?这将是我的preferred的方法,因为它主要环境无关。有没有人有这种做法的经验吗?我想这将只需要保留一个旧版本,如果可以进行所有的测试通过,如果最新版本的性能至少与以前的版本一样好。

Or maybe the answer is to keep older versions of the program and compare results before and after? This would be my preferred method, since it's mostly environment agnostic. Does anyone have experience with this approach? I imagine it would only be necessary to keep one older version if all the tests can be made to pass if the performance of the latest version is at least as good as the former version.

推荐答案

我怀疑是应用TDD带动业绩是一个错误。通过一切手段,用它来获得好的设计和工作code,并利用写在TDD的过程中测试,以确保持续的正确性 - 但一旦你有良好分解code和测试了坚实的套件,你是在良好的状态来调整,而不同(从TDD)技术和工具应用。

I suspect that applying TDD to drive performance is a mistake. By all means, use it to get to good design and working code, and use the tests written in the course of TDD to ensure continued correctness - but once you have well-factored code and a solid suite of tests, you are in good shape to tune, and different (from TDD) techniques and tools apply.

TDD为您提供了良好的设计,可靠的code和测试覆盖的安全网。这使您转换成调优的好地方,但我认为这是因为你和其他人提到的问题,它只是不会占用你太多进一步下跌调谐的道路。我说,作为一个伟大的风扇和TDD的支持者和实践者。

TDD gives you good design, reliable code, and a test coverage safety net. That puts you into a good place for tuning, but I think that because of the problems you and others have cited, it's simply not going to take you much further down the tuning road. I say that as a great fan and proponent of TDD and a practitioner.

这篇关于性能做TDD测试时的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆