ITeye博客

模拟大并发访问量请求程序(压力测试)

tof.j · 2008-09-02 11:06 · Markdown

import java.io.InputStream;
import java.net.URL;
 
 
public class TestURL
{
    public static void main(String[] args) throws Exception
    {
      long a = System.currentTimeMillis();
      System.out.println("Starting request url:");
      InputStream is = null;
        for(int i = 0; i < 100; i++){//此处的值可以根据需求增加
          URL url = new URL("http://qixiaorui.blog.chinajavaworld.com/entry/847/0/");//此处填写供测试的url
          is = url.openStream();
          System.out.println("Starting request url:"+i);
        }
        System.out.println("request url end.take "+(System.currentTimeMillis()-a)+"ms");
        is.close();
    }
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。