Skip to content

Instantly share code, notes, and snippets.

@bluemonk
Created August 9, 2010 16:19
Show Gist options
  • Select an option

  • Save bluemonk/515648 to your computer and use it in GitHub Desktop.

Select an option

Save bluemonk/515648 to your computer and use it in GitHub Desktop.
n = 50_000
Benchmark.bm do|b|
b.report("ipaddr ") do
n.times { IPAddr.new("192.168.10.100").to_s }
end
b.report("ipaddress parse ") do
n.times { IPAddress.parse("192.168.10.100").to_s }
end
b.report("ipaddress ipv4 ") do
n.times { IPAddress::IPv4.new("192.168.10.100").to_s }
end
end
user system total real
ipaddr 12.680000 3.750000 16.430000 ( 17.251509)
ipaddress parse 13.090000 1.550000 14.640000 ( 15.311803)
ipaddress ipv4 12.490000 1.310000 13.800000 ( 14.335803)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment