https://github.com/agentcooper/typescript-node-worker-threads-map-example
Example of mapping an array using workers.
https://github.com/agentcooper/typescript-node-worker-threads-map-example
Last synced: 20 days ago
JSON representation
Example of mapping an array using workers.
- Host: GitHub
- URL: https://github.com/agentcooper/typescript-node-worker-threads-map-example
- Owner: agentcooper
- Created: 2020-06-11T15:42:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-11T15:42:53.000Z (about 6 years ago)
- Last Synced: 2025-03-02T18:28:43.977Z (over 1 year ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Example of mapping an array using [workers](https://nodejs.org/api/worker_threads.html).
To run make sure you're using Node version >=12.
## Install
```
npm install
npm run build
```
## Run
```
~/typescript-node-worker-threads-map-example % node ./build/index.js
[
2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44,
46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66,
68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
90, 92, 94, 96, 98, 100
]
Computation: 11256.496ms
```
```
~/typescript-node-worker-threads-map-example % node ./build/index-without-workers.js
[
2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44,
46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66,
68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
90, 92, 94, 96, 98, 100
]
Computation: 27433.186ms
```