Skip to content

Instantly share code, notes, and snippets.

@rb2k
Created December 13, 2009 16:21
Show Gist options
  • Save rb2k/255476 to your computer and use it in GitHub Desktop.
Save rb2k/255476 to your computer and use it in GitHub Desktop.
require "dnsruby"
require 'benchmark'
url_list = ["marc-seeger.de", "facebook.com", "google.com", "yahoo.com", "www.hdm-stuttgart.de", "spiegel.de", "heise.de", "golem.de", "reddit.com", "imdb.com"]
nameservers = Hash.new
nameservers["8.8.8.8"] = "Google"
nameservers["8.8.4.4"] = "Google"
nameservers["208.67.222.222"] = "OpenDNS"
nameservers["208.67.220.220"] = "OpenDNS"
nameservers["67.138.54.100"] = "Scrubit"
nameservers["207.225.209.66"] = "Scrubit"
nameservers["156.154.70.1"] = "DNS Advantage"
nameservers["156.154.71.1"] = "DNS Advantage"
nameservers["85.214.73.63"] = "FoeBuD"
nameservers["64.81.79.2"] = "Keine Ahnung"
nameservers["147.144.1.251"] = "Keine Ahnung"
nameservers["69.111.95.106 "] = "Keine Ahnung"
nameservers["129.143.2.4"] = "Belwue"
nameservers["129.143.2.1"] = "Belwue"
puts "Starting benchmark with #{nameservers.size} servers and #{url_list.size} URLs"
result = Hash.new
nameservers.keys.each_with_index do |ns_ip,index|
print "checking [#{index+1}/#{nameservers.size}] #{ns_ip}"
time = Benchmark.realtime{
url_list.each do |url|
Dnsruby::Resolver.new(:nameserver => ns_ip).query(url, Dnsruby::Types.A)
end
}
result[ns_ip] = time
puts "\t-> done!"
end
puts "The results (fastest server first)"
result_sorted = result.sort{|item1, item2| item1[1] <=> item2[1]}
result_sorted.each do |item|
puts "#{item[0]} #{nameservers[item[0]]}:\t\t\t #{item[1].to_s[0,5]} seconds"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment