-
|
Hi, Is there any chance you could create a complete example showing how to send a request to a WebWorker and have the result be returned as a Transferable object? i've been trying to do that with a background task i've been trying to optimize - it's currently taking ~9s with JSON and ~6s with a memory packed byte array - those 6s appear to be the time it takes from the serialization completing and getting the data from the WebWorker to the Window task and adding |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
|
Basically, i would like to see a example showing a method that accepts a ArrayBuffer and pretty much just returns it right back - preferably with a roundtrip Stopwatch to see how long it takes to send a ~250kb blob of data. |
Beta Was this translation helpful? Give feedback.
-
|
Hope this helps. I changed the amount of data to 50MB. When I used 250KB there wasn't a noticeable difference.
Example output from the demo: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you - that's perfect - and i realized late last night that i had messed up my measurements - i was naively thinking that i could get a timestamp using Stopwatch.GetTimestamp() from within the WebWorker to then compare that against an equivalent Timestamp from the outside and get the difference between them as the time it takes to transfer the data - that doesn't work since Stopwatch doesn't give you an exact timestamp from a given point in time - it's instead (from my understanding now) based on how long the process has been running essentially which is obviously going to be different between the WebWorker and the main UI thread. |
Beta Was this translation helpful? Give feedback.
-
|
I modified that example some. There are now 3 tests. Test 3 takes and returns a |
Beta Was this translation helpful? Give feedback.
Hope this helps. I changed the amount of data to 50MB. When I used 250KB there wasn't a noticeable difference.
WorkerTransferExample
Live Demo
Example output from the demo: