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
| const { parentPort } = require('worker_threads'); | |
| function blockForSeconds(seconds) { | |
| const startTime = Date.now(); | |
| let endTime = startTime; | |
| while (endTime - startTime < seconds * 1000) { | |
| endTime = Date.now(); | |
| } | |
| } |
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
| function blockForSeconds(seconds) { | |
| const startTime = Date.now(); | |
| let endTime = startTime; | |
| while (endTime - startTime < seconds * 1000) { | |
| endTime = Date.now(); | |
| } | |
| } | |
| function run() { | |
| const startTime = performance.now(); |
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
| function createSamples(name, createVariation) { | |
| const sampleCount = 10000; | |
| const variations = []; | |
| for (let i = 0; i < sampleCount; i++) { | |
| variations.push(createVariation()); | |
| } | |
| const countData = variations.reduce((accum, curr) => { | |
| if (accum[curr]) { |