Created
June 1, 2011 14:35
-
-
Save woochica/1002410 to your computer and use it in GitHub Desktop.
Testing JSON parsing speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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