Skip to content

Instantly share code, notes, and snippets.

@Torxed
Last active August 29, 2015 14:02
Show Gist options
  • Save Torxed/d947bb4cc67e0e2ca1e2 to your computer and use it in GitHub Desktop.
Save Torxed/d947bb4cc67e0e2ca1e2 to your computer and use it in GitHub Desktop.
A short test in lookup-times on DNS records.
#!/usr/bin/python3
from socket import gethostbyname
from time import *
domains = ('cobra.com', 'tiger.com', 'ferrarri.com', 'amazon.com', 'thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com', 'sockervadd.se')
for domain in domains:
start = time()
## This instructs the OS to do a DNS lookup.
gethostbyname(domain)
end = time()
print(domain,'took',end-start,'seconds to lookup')
# == Results in:
# [torxed@archie ~]$ python test.py
# cobra.com took 0.3517730236053467 seconds to lookup
# tiger.com took 0.43889451026916504 seconds to lookup
# ferrarri.com took 0.40071821212768555 seconds to lookup
# amazon.com took 0.1225285530090332 seconds to lookup
# thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com took 1.157090425491333 seconds to lookup
# sockervadd.se took 0.11581301689147949 seconds to lookup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment