如何在BlackBerry中捕获HTTP吞吐量?

如何在BlackBerry中捕获HTTP吞吐量?,http,blackberry,throughput,Http,Blackberry,Throughput,请帮助我查找BB编程中的HTTP吞吐量和HTTP延迟。您可以使用System.currentTimeMillis()获取代码中各个点的时间戳,然后使用这些值计算计时。例如: long start = System.currentTimeMillis(); HttpConnection connection = (HttpConnection) Connector.open(url); long opened = System.currentTimeMillis(); String body =

请帮助我查找BB编程中的HTTP吞吐量和HTTP延迟。

您可以使用
System.currentTimeMillis()
获取代码中各个点的时间戳,然后使用这些值计算计时。例如:

long start = System.currentTimeMillis();
HttpConnection connection = (HttpConnection) Connector.open(url);
long opened = System.currentTimeMillis();
String body = new String(IOUtilities.streamToBytes(connection.openInputStream()));
long done = System.currentTimeMillis();

long bytes = body.length();
float durationSeconds = (float)(done - opened) / 1000.0f;
float bytesPerSecond = bytes / durationSeconds;

System.out.println("Latency: " + (opened - start) + " ms");
System.out.println("Bandwidth: " + bytesPerSecond + " bytes per second");