===================
Performance checks
===================

  >>> import os.path
  >>> import p01.geo.locator

  >>> path = os.path.join(os.path.dirname(p01.geo.__file__), 'data')
  >>> db = os.path.join(path, 'GeoLiteCity.dat')
  >>> tzdb = os.path.join(path, 'timezone.txt')

  >>> locator = p01.geo.locator.GeoLocator(db, tzdb)

  >>> import time
  >>> import random
  >>> r = random.Random(42)

  >>> def genIP():
  ...     ip = "%s.%s.%s.%s" % (r.randint(1,254), r.randint(0,254), r.randint(0,254), r.randint(0,254))
  ...     return ip

First measure the time needed for random IP generation

  >>> start = time.time()
  >>> count = 10000
  >>> for i in xrange(count):
  ...    ip = genIP()

  >>> end = time.time()
  >>> duration = end-start
  >>> oneRandomIP = duration/(count*1.0)

Then the lookups:

  >>> start = time.time()
  >>> for i in xrange(count):
  ...    ip = genIP()
  ...    d = locator.getData(ip)

  >>> end = time.time()
  >>> duration = end-start
  >>> one = (duration/(count*1.0)) - oneRandomIP
  >>> print "%03.10f" % one
  0.0001...


  >>> start = time.time()
  >>> for i in xrange(count):
  ...    ip = genIP()
  ...    d = locator.getTimeZone(ip)

  >>> end = time.time()
  >>> duration = end-start
  >>> one = (duration/(count*1.0)) - oneRandomIP
  >>> print "%03.10f" % one
  0.0001...

Cached lookup:

  >>> ip = '86.101.28.131'
  >>> start = time.time()
  >>> for i in xrange(count):
  ...    d = locator.getTimeZone(ip)

  >>> end = time.time()
  >>> duration = end-start
  >>> one = (duration/(count*1.0))

Just hell fast:

  >>> print "%03.10f" % one
  0.0000006...
