-
-
Save ringsaturn/1929f943e77552473d910997a9eda43d to your computer and use it in GitHub Desktop.
This file contains 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
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) | |
This file contains 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
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