forked from krpeacock/certified-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.blast
More file actions
1 lines (1 loc) · 1.21 KB
/
Copy pathtest.blast
File metadata and controls
1 lines (1 loc) · 1.21 KB
1
{"cells":[{"kind":2,"language":"javascript","value":"const {default: plimit} = await import(\"https://cdn.jsdelivr.net/npm/p-limit@4.0.0/+esm\"); // So we can limit the concurrent async requests. Promise.all will crash vscode if too many requests are made.\n\nlet local = icblast({local:true, local_host: \"http://localhost:8080\"});\n\nlet can = await local(\"be2us-64aaa-aaaaa-qaabq-cai\");\n\nfunction generateRandomUint8Array() {\n // Generate a random length around 300KB\n const randomLength = Math.floor(Math.random() * 10 + 20) * 1024; \n\n // Create a new Uint8Array of that length\n let array = new Uint8Array(randomLength);\n\n // Fill the array with random values\n for(let i = 0; i < array.length; i++) {\n array[i] = Math.floor(Math.random() * 256);\n }\n\n return array;\n}\n\nconst limit = plimit(20); // Max 20 concurrent requests\n\nawait Promise.all(Array(500).fill(0).map((_) => limit(() => {\n let sss = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" + Math.random()\n return can.upload(sss, generateRandomUint8Array()).catch(e => {\n log([sss, e]);\n })\n})\n));\n\n"}]}