Created
March 28, 2018 11:05
-
-
Save bwindels/d75a8cfd0566f274dddeb9acb874f76b 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function runWorker() { | |
function createMessage(n) { | |
return { | |
"foo": "bar", | |
"body": "hello world " + n, | |
"date": Date.now() | |
}; | |
} | |
let messages = []; | |
for(let i = 0; i < 100000; ++i) { | |
messages.push(createMessage(i)); | |
} | |
for(let i = 0; i < 10; ++i) { | |
postMessage(messages); | |
} | |
} | |
let workerBlob = new Blob([runWorker.toString(), "runWorker();"]); | |
let blobURL = window.URL.createObjectURL(workerBlob); | |
let worker = new Worker(blobURL); | |
worker.addEventListener('message', msg => { | |
console.log(msg.data.length); | |
}); | |
</script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment