views:

296

answers:

1

Scenario
I'm doing analytics of a data connection being made via Java's HttpConnection. Specifically, I want to measure:

  • Time it took to receive the response header (not the full response)
  • Time it took to download the data (not the full request, the response)

To me, it seems as if the HttpConnection class is not sophisticated enough report these metrics (via events or overriding specific methods).

Final Questions
Does Java's HttpConnection allow for granular measurement/analysis of the steps associated with a data request (measure time to retrieve just the header, time to retrieve just the body data)? If so, how can this be done?

+1  A: 

The easiest way, if you are going from the server to the Blackberry, is to send just an empty response, so all you are measuring is the header.

If you can connect and just get the empty response without having to send any data to the server, that would be best, as it just includes the time to send the request to the server, but that should be largely negligible.

You are doing all the measuring on the from the Blackberry, so just measure the roundtrip time, since the request should not take long enough to matter.

I would do this in a loop, 1000 times, and take the max time, min time and average time. This will give you an idea.

Then, for the body, you have the average time for the header, so do the same call with the body now being included, and do it again about 1000 times, with the same three numbers, and you can then subtract the average header from the average body and get a rough estimate.

Whenever you are measuring over the Internet average time is best, as there can be a large number of variables that will affect the time to send data.

James Black
Hi James, thanks for this! Though I should clarify, this metric analysis is going into a production application. Specifically, we're interested in measuring how long it takes to process a response clientside (blackberry) and then send that data back as a chunk of metrics in a lazy (second priority) http data queue. In this context, is it even possible in measuring the parsing of the header and body content of the HTTP response?
AtariPete
I don't see how to separate the time to load each part, but, by doing some testing you should get a rough idea as to the time involved. If you send back the time to send the entire packet you should have a fairly good idea as to how much time is spent on downloading the header and body, so you should be able to calculate the estimate on the server-side, given the time to d/l the entire packet. This is statistical, but it may be the best approach.
James Black