How can my Ruby “Time.now” timings be so low when my “ping” timings are so high?

You could start a packet sniffer, start irb, and then issue some test commands one line at a time, but you already seem to have accurately analyzed its dynamic behavior So, I suppose you got coll with something like coll = db. Collection_names? And I suppose coll must be an Enumerable?

If so, nothing really needs to happen in that call except the return of an object with an each method. Perhaps nothing actually does happen until you ask for something from the Enumerable You might try: time1 = Time. Now rows = coll.

Find(some_criteria) o = rows. First puts ((Time. Now - time1) * 1000).

To_s This won't necessarily take any longer. It's possible that the work was done when db. Collection_names was called.

The irb test, from the top, might shed some light on the issue.

You could start a packet sniffer, start irb, and then issue some test commands one line at a time, but you already seem to have accurately analyzed its dynamic behavior. So, I suppose you got coll with something like coll = db. Collection_names?

And I suppose coll must be an Enumerable? If so, nothing really needs to happen in that call except the return of an object with an each method. Perhaps nothing actually does happen until you ask for something from the Enumerable.

You might try: time1 = Time. Now rows = coll. Find(some_criteria) o = rows.

First puts ((Time. Now - time1) * 1000). To_s This won't necessarily take any longer.It's possible that the work was done when db.

Collection_names was called. The irb test, from the top, might shed some light on the issue...

I'm ssh'ed into the remote host to, watching MongoDB's verbose output, and from that output I KNOW there is a network round trip going on. So, I'm just baffled by the difference in ping time versus the time that ruby measures. – Corey Trager Nov 22 '09 at 14:15 1 It may simply return an Enumerable AND also start a socket op for which it doesn't need a synchronous result.

This would launch a round trip but also return immediately. – DigitalRoss Feb 7 '10 at 4:40.

Simple answer: this line isn't doing what you expect: rows = coll. Find(some_criteria) specifically, it's not communicating with the server.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions