Created
June 22, 2012 07:18
-
-
Save auxesis/2970957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'socket' | |
i = 10_000 | |
Benchmark.bm(9) do |x| | |
x.report("shell out") do | |
i.times { `hostname -f`.strip } | |
end | |
x.report("socket") do | |
i.times { Socket.gethostbyname(Socket.gethostname).first } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ ➔ ruby fqdn-benchmark.rb | |
user system total real | |
shell out 1.280000 11.500000 38.610000 ( 49.029772) | |
socket 1.330000 2.220000 3.550000 ( 22.050667) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment