Skip to content

Instantly share code, notes, and snippets.

@allcentury
Created May 12, 2015 15:06
Show Gist options
  • Save allcentury/08ab203dec55f1ebd1ad to your computer and use it in GitHub Desktop.
Save allcentury/08ab203dec55f1ebd1ad to your computer and use it in GitHub Desktop.
require 'socket'
puts "Using send with a host:"
s = UDPSocket.new
before_time = Time.now
100_000.times do |i|
s.send("#{i}", 0, 'localhost', 1234)
end
puts "Time elapsed was #{Time.now - before_time}"
puts "----------------------------\n\n\n"
puts "Connecting before using send"
s = UDPSocket.new
before_time = Time.now
s.connect('127.0.0.1', 1234)
100_000.times do |i|
s.send("#{i}", 0)
end
puts "Time elapsed was #{Time.now - before_time}"
puts "----------------------------\n\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment