Denis Haskin
12/23/2008 6:03:00 PM
[Note: parts of this message were removed to make it a legal post.]
I have some simple network performance analysis I need to do; easiest
and most flexible thing to do would be to use Net::HTTP in Ruby to do
this, but I want to make sure I'm getting somewhat realistic results.
(Note since I'm mainly using this for comparisons, not specific timings,
the numbers don't need to be *exact*, but would be nice if they were close.)
In any event, I'm using Net::HTTPResponse#read_body since I want to be
able to get intra-download timings, so I've got something like:
Net::HTTP.start(url.host, url.port) do |http|
http.request_get('/test.txt') do |res|
# start timer
res.read_body do |fragment|
# stop timer, calculate stats for this interval & fragment size
# restart timer
end
end
end
The numbers I'm getting seem *somewhat* right but vary a lot,
particularly because each fragment is pretty small (doc says it's as it
comes from the socket).
Does anyone know if read_body is synchronous wrt to the network reads?
E.g. is it realistic to use this for timing this way? I'll do some
comparisons with wget, but any help would be appreciated.
Thanks,
dwh