Skip to content

Instantly share code, notes, and snippets.

@woochica
Created June 1, 2011 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woochica/1002410 to your computer and use it in GitHub Desktop.
Save woochica/1002410 to your computer and use it in GitHub Desktop.
Testing JSON parsing speed
from __future__ import with_statement
import simplejson as json
import time
class Timer(object):
def __enter__(self):
self.__start = time.time()
def __exit__(self, type, value, traceback):
# Error handling here
self.__finish = time.time()
def duration_in_seconds(self):
return self.__finish - self.__start
timer = Timer()
with timer:
with open('fixtures/migrated_tender.json') as f:
doc = json.load(f)
print timer.duration_in_seconds()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment