开发者

Optimized ping with threads in ruby, possible?

开发者 https://www.devze.com 2023-03-29 19:21 出处:网络
I am using ruby 1.8.7 and I cannot upgrade to 1.9+ anytime soon. 开发者_JAVA技巧I understand that ruby has green threads, and anything cpu based does not gain much by way of multithreading.

I am using ruby 1.8.7 and I cannot upgrade to 1.9+ anytime soon.

开发者_JAVA技巧I understand that ruby has green threads, and anything cpu based does not gain much by way of multithreading.

However, I was trying a multithreaded ping in ruby, as in my script will try to ping N machines in the network -- in the time a machine replies back there's enough time to create a new thread and initiate connection with another host. However what I see is that multithreading has actually worsened performance.

Any suggestions to do an optimized ping with threads in ruby?


You should use EventMachine with an ICMP implementation. The author of icmp4em also provides two examples how to use all this stuff.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号