Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.