Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Last active March 22, 2022 14:57
Show Gist options
  • Save masahitojp/ed54c460450d50cac6ab95e817d20e8d to your computer and use it in GitHub Desktop.
Save masahitojp/ed54c460450d50cac6ab95e817d20e8d to your computer and use it in GitHub Desktop.
It's a benchmark for simdjson vs json on python 3.10
import simdjson
import json
import timeit
parser = simdjson.Parser()
def test(s):
doc = parser.parse(s)
return doc
def test_simplejson(s):
doc = json.loads(s)
return doc
loop =1000
with open("./canada.json") as f:
s = f.read()
result = timeit.timeit("test(s)", globals=globals(), number = loop)
print(result/loop)
result = timeit.timeit("test_simplejson(s)", globals=globals(), number = loop)
print(result/ loop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment