0
請幫助我找出BB編程中的HTTP吞吐量和HTTP延遲。如何在BlackBerry中捕獲HTTP吞吐量?
請幫助我找出BB編程中的HTTP吞吐量和HTTP延遲。如何在BlackBerry中捕獲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");
問題沒有什麼意義。 – 2010-02-04 13:47:06