标题: Unit testing for speed?(在单元测试中考虑性能测试) [打印本页] 作者: skinapi 时间: 2005-7-27 15:46 标题: Unit testing for speed?(在单元测试中考虑性能测试) Unit testing for speed?
I was just thinking about performance testing, and wondered if writing a unit test would be sensible. If a functional requirement is, for example, "Import all of the data in the crime scene XML file into the database within 0.5 seconds", a test could be written to:
Get the time into startTime
Call the ImportCrimeSceneData method
Get the time into endTime
Assert endTime < startTime + 0.5 seconds
If this fails, then the ImportCrimeSceneData method can be tuned until it passes. Once it has passed, then any future changes to the method are checked automatically to ensure that the limit isn't exceeded.
Although the idea seems like it would work, it feels like a wrong thing to do. Has anyone else done this successfully, or can anyone give me an actual reason why this is wrong (other than "it just feels like it")?作者: skinapi 时间: 2005-7-27 15:57
一些参与讨论的人还提供了以下链接供学习参考: http://javapronews.com/javaprone ... gwithJUnitPerf.html