web程序开发完毕,如何做压力测试?

aloie 2009-09-16 11:50:50
如题,包括同时在线压力测试,数据库交互压力测试,有工具还是需要自己写代码?常用哪种?
...全文
521 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
DryKillLogic 2009-09-16
  • 打赏
  • 举报
回复
哦。。。。。学习了
qyhdt 2009-09-16
  • 打赏
  • 举报
回复
帮顶下 我也在寻找
qingkangxu 2009-09-16
  • 打赏
  • 举报
回复
最简单的就是用线程和apache的httpclient(http://hc.apache.org/)
1,new 10几20几个线程。
2,每个线程里都用httpclient访问你的web应用。
当然,你也可以用java.net.HttpURLConnection来访问你的web应用
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class HttpURLConnectionTest1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
URL serverURL = null;
URLConnection serverConnection = null;
try {
serverURL = new URL("http://localhost:80/yourURL");
System.out
.println("-------------------------------- First --------------------------------");
serverConnection = getURLConnection(serverURL);

//serverConnection.setRequestProperty(key, value);

writeRequest(serverConnection);
printResponse(serverConnection);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {

}
}

private static URLConnection getURLConnection(URL serverURL)
throws IOException {
URLConnection serverConnection = serverURL.openConnection();
if (serverConnection instanceof HttpURLConnection) {
// Set the appropriate attributes to the server connection
serverConnection.setDoInput(true);
serverConnection.setDoOutput(true);
serverConnection.setUseCaches(false);

// Specify the connection to use only post method.
((HttpURLConnection) serverConnection).setRequestMethod("POST");
}
return serverConnection;
}

protected static void writeRequest(URLConnection serverConnection)
throws IOException {
OutputStream serverOutputStream = serverConnection.getOutputStream();
serverOutputStream.write("Your Messsage".getBytes());
serverOutputStream.flush();
serverOutputStream.close();
}

private static void printResponse(URLConnection serverConnection)
throws IOException {
System.out.println("-----------------------Following are Response Message-----------------------");
// print header information
int responseCode = ((HttpURLConnection) serverConnection)
.getResponseCode();
System.out.println("ResponseCode:" + responseCode);

InputStream is = serverConnection.getInputStream();
int a;
System.out.println("Response Message=======================");
while ((a = is.read()) != -1) {
System.out.write(a);
}
System.out.write("\n".getBytes());
System.out.flush();

is.close();
}
}
aa147967084 2009-09-16
  • 打赏
  • 举报
回复
帮顶下
lee90649 2009-09-16
  • 打赏
  • 举报
回复
学习来了!~
bdceo 2009-09-16
  • 打赏
  • 举报
回复
loaderRunner9.x或8.x得版本性能不错,可以下载测试。。。
aloie 2009-09-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 gudufeiyang 的回复:]
有时候还需要 多造点数据,否则结果的意义也不大。
[/Quote]

最好是能模拟n多人同时在线提交数据,有没有这样的测试工具?
  • 打赏
  • 举报
回复
jmeter
Billy.Wang 2009-09-16
  • 打赏
  • 举报
回复
有时候还需要 多造点数据,否则结果的意义也不大。
gordonkkk 2009-09-16
  • 打赏
  • 举报
回复
LoadRunner
wang8 2009-09-16
  • 打赏
  • 举报
回复
学习
美人心计1999 2009-09-16
  • 打赏
  • 举报
回复
rosewj 2009-09-16
  • 打赏
  • 举报
回复
学习学习
liwenso 2009-09-16
  • 打赏
  • 举报
回复
用Apach的工具
bea_java 2009-09-16
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 bdceo 的回复:]
loaderRunner9.x或8.x得版本性能不错,可以下载测试。。。
[/Quote]ffdff
phoenixYiYou 2009-09-16
  • 打赏
  • 举报
回复
同意LoadRunner,非常经典!有破解版!呵呵!不过,要花一点功夫学一下!呵呵!
ms_X0828 2009-09-16
  • 打赏
  • 举报
回复
up
学习.....

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧