Created
February 13, 2024 12:02
-
-
Save nurkiewicz/74f530cccd8424c92223926e1d719d0f to your computer and use it in GitHub Desktop.
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
const fs = require('fs') | |
const json = fs.readFileSync('large.json').toString() | |
// Run this several times, collect times in spreadsheet, like an animal | |
start = Date.now(); JSON.parse(json); Date.now() - start |
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
import json | |
import uuid | |
def generate_large_json(num_objects): | |
data = {} | |
for i in range(num_objects): | |
data['key-' + str(i)] = { | |
'id': i, | |
'name': 'name-' + str(uuid.uuid4()), | |
'value': uuid.uuid4().hex * 10, | |
'data': generate_large_json(int(num_objects / 10)) if num_objects > 5 else {} | |
} | |
return data | |
json.dump(generate_large_json(100), open('large.json', 'w'), indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment