-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Junyu Wang
committed
May 15, 2024
1 parent
acf21dd
commit 685cf2a
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
This script generates a JSON file with a size of 50MB, 500MB and 3GB. | ||
""" | ||
import json | ||
|
||
three_gb_json_count = 10000000 | ||
five_hundred_mb_json_count = three_gb_json_count // 6 | ||
fifty_mb_json_count = three_gb_json_count // 60 | ||
|
||
data = [] | ||
for i in range(five_hundred_mb_json_count): | ||
charge = { | ||
"status": "success", | ||
"data": { | ||
"order_id": "123456789", | ||
"customer": { | ||
"name": "John Doe", | ||
"email": "johndoe@example.com", | ||
"address": { | ||
"street": "123 Main St", | ||
"city": "San Francisco", | ||
"state": "CA", | ||
"zip": "94101" | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"id": "item1", | ||
"name": "Product 1", | ||
"price": 99.99 | ||
}, | ||
{ | ||
"id": "item2", | ||
"name": "Product 2", | ||
"price": 49.99 | ||
} | ||
], | ||
"total_amount": 149.98 | ||
} | ||
} | ||
if i % 2 == 0: | ||
charge["status"] = "failed" | ||
charge["data"].pop("items") | ||
if i % 3 == 0: | ||
charge["metadata"] = { | ||
"notes": "This is a test charge" | ||
} | ||
data.append(charge) | ||
|
||
# Write the JSON data to a file | ||
with open("test_medium_500mb_full_json_array.json", "w") as file: | ||
# json_text = "\n".join([json.dumps(charge) for charge in data]) | ||
# file.write(json_text) | ||
json.dump(data, file) | ||
|