如何使用java测试无线连接速度?

时间:2017-10-27 01:43:17

标签: java performance wifi

在我的编译器中,如何测试计算机的无线连接速度?

1 个答案:

答案 0 :(得分:0)

您可以尝试从互联网上下载文件,只需使用开始/结束计时器

Long start = System.nanoTime();

// download to file code goes here
URL website = new URL("http://central.maven.org/maven2/com/sun/jersey/jersey-client/1.0.2/jersey-client-1.0.2.jar");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("information.html");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

// do some validation check here that the file is successfully downloaded
Long end = System.nanoTime();
// and then measure time. you get file size (bytes) which you can use to measure speed

还值得一读Neflix fast.com实施here