有Android中任何类可用于测量网页加载时间? [英] Is there any class in Android that can be used to measure the web page load time?

查看:101
本文介绍了有Android中任何类可用于测量网页加载时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较的3G网络和WiFi之间的网页加载时间,所以我要寻找可以在android系统被用于此目的的类。

I am trying to compare the web page loading time between 3G network and WiFi, so I am looking for classes that can be used in android for this purpose.

但到目前为止,我还没有发现任何非常有用的类。

But so far I have not found any very useful class.

有没有人做过这并没有你们用什么?

Has anybody done this before and what did you guys use?

在此先感谢:)

推荐答案

我认为这将帮助您:使用不同的网络连接执行此:

I think this will help you: Execute this with different network connections:

//start a timer here
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try 
{
   InputStream in = new BufferedInputStream(urlConnection.getInputStream());
   readStream(in);
   //End timer after read stream. Log the time difference.
   finally 
   {
     urlConnection.disconnect();
   }
}

这篇关于有Android中任何类可用于测量网页加载时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆