# Bm + net/http sanity check

**URL:** <https://www.ruby-forum.com/t/bm-net-http-sanity-check/60862>\
**Category:** Ruby\
**Created:** [May 18, 2006, 1:01am UTC](https://www.ruby-forum.com/t/bm-net-http-sanity-check/60862 "2006-05-18T01:01:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/u/DEBAUNS_STEVE_SAG-C)\
**Post date:** [May 18, 2006, 1:01am UTC](https://www.ruby-forum.com/t/bm-net-http-sanity-check/60862/1 "2006-05-18T01:01:04Z")

</div>

Hey all,

I’m using this in a quick-n-dirty script:

Benchmark.bm { |bm|

```
  [root1, root2].each_with_index { |host,i|

    bm.report("HTTP Host ##{i}: #{host}") {

  Net::HTTP.get host, "/#{stem}"

    }

  }

  [root1, root2].each_with_index { |host,i|

        r = `ping #{host}`[/Average = (.*)ms/]

        puts "Ping Host ##{i+1}: #{r}"

  }

```

}

To benchmark response times for two different websites.

Is there anything I’m incorrectly assuming about the Net::HTTP stuff, or  
does this sound like a reasonable comparison?

Only reason I’m asking: ping delta is about 100 ms, but the Net::HTTP  
delta  
is about 700 ms. This does not jive with what I’m expecting, at all.

sd

---

<div class="post-metadata">

**Author:** ![DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/u/DEBAUNS_STEVE_SAG-C)\
**Post date:** [May 18, 2006, 1:50am UTC](https://www.ruby-forum.com/t/bm-net-http-sanity-check/60862/2 "2006-05-18T01:50:33Z")

</div>

> Only reason I’m asking: ping delta is about 100 ms, but the Net::HTTP delta  
> is about 700 ms. This does not jive with what I’m expecting, at all.

Maybe consider the relative delta. The GET request should take quite a  
bit longer than an ICMP echo, even if you don’t take the fact that one  
is running in a benchmark framework of a scripting language and the  
other is probably an OS executable.

These are different sites at different locations you’re benchmarking,  
correct? Maybe different technologies were used, one is serving static  
pages, the other has really screwy dynamic pages with an Access  
backend…

Also, doesn’t `.get` actually download the content? Maybe the one page  
is way bigger than the other?

-tim

---

<div class="post-metadata">

**Author:** ![DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@DEBAUNS\_STEVE\_SAG-C](https://www.ruby-forum.com/u/DEBAUNS_STEVE_SAG-C)\
**Post date:** [May 18, 2006, 1:57am UTC](https://www.ruby-forum.com/t/bm-net-http-sanity-check/60862/3 "2006-05-18T01:57:24Z")

</div>

Quoting removed\_email\_address@domain.invalid, on Thu, May 18, 2006 at 07:58:28AM  
+0900:

> Only reason I’m asking: ping delta is about 100 ms, but the Net::HTTP delta  
> is about 700 ms. This does not jive with what I’m expecting, at all.

Why not? Sounds ok, setting up, using, and closing down a tcp line  
should take at least 3 roundtrips, I think, so you’d need at least 300,  
and if the data transfer takes a bit of time, bit of tcp stack overhead,  
bit of software doing stuff… sounds like 700 ms.

running tcpdump might tell you exactly whats going on, with pretty  
accurate timestamps.

Cheers,  
Sam
