Skip to content

Instantly share code, notes, and snippets.

@ringsaturn
Last active July 30, 2019 09:55
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 ringsaturn/1929f943e77552473d910997a9eda43d to your computer and use it in GitHub Desktop.
Save ringsaturn/1929f943e77552473d910997a9eda43d to your computer and use it in GitHub Desktop.
import time
import orjson
import nujson
import pandas._libs.json as pdujson
with open("test.json") as f:
json_str = f.read()
n = 30000
# --------------------------------------------------------------------------- #
start = time.process_time()
for i in range(n):
nujson.loads(json_str)
elapsed = (time.process_time() - start)
print("nujson time used:", elapsed)
# --------------------------------------------------------------------------- #
start = time.process_time()
for i in range(n):
orjson.loads(json_str)
elapsed = (time.process_time() - start)
print("orjson time used:", elapsed)
# --------------------------------------------------------------------------- #
start = time.process_time()
for i in range(n):
pdujson.loads(json_str)
elapsed = (time.process_time() - start)
print("pandas time used:", elapsed)
nujson time used: 2.7183710000000003
orjson time used: 6.190265
pandas time used: 2.9665549999999996
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment