【发布时间】:2014-04-09 20:25:11
【问题描述】:
真的和带宽计算公式混淆了。
参考带宽检测问题Check the bandwidth rate in Android 我正在尝试按以下方式计算带宽。
long startTime = System.currentTimeMillis();
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
long contentLength = httpEntity.getContentLength();
long endTime = System.currentTimeMillis();
float bandwidth = contentLength / ((endTime-startTime) / 1000); // In the refereed question it is "((endTime-startTime) * 1000)" don't know why multiplication.
我需要的是当前带宽(不是字节或千字节)。如果它是以字节或位计算带宽,我不知道使用上面的公式。
如果下载时间为 0 秒,那么带宽应该是下载内容的长度。 有人可以建议正确的公式来计算以比特为单位的带宽。
【问题讨论】: