51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2424|回复: 1
打印 上一主题 下一主题

Unit testing for speed?(在单元测试中考虑性能测试)

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2005-7-27 15:46:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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")?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2005-7-27 15:57:04 | 只看该作者
一些参与讨论的人还提供了以下链接供学习参考:
http://javapronews.com/javaprone ... gwithJUnitPerf.html

我的看法:
1、什么时候开始性能测试有时候是一件很难确定但又必须去面对的事情,不是只有系统测试阶段需要考虑性能测试,单元测试、集成测试阶段都有可能和性能测试拉上关系。
2、文中提到如果在单元测试阶段就考虑性能测试,这样在代码发生改变或者对代码进行了优化时就能看出这些改变是否会影响到性能,能尽早的发现代码变更对性能的影响。
3、一个系统的性能如果拆分来看,可以看成若干单元性能的一个有机结合,单元的性能势必也会对整个系统的性能产生影响,所以尽早考虑性能测试是很必要的,当然这需要很好的分析和设计了。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-21 18:54 , Processed in 0.074989 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表