-import { isMaster } from 'cluster'
+import { isPrimary } from 'cluster'
import { ClusterWorker } from '../../lib/index.mjs'
import { executeTaskFunction } from '../benchmarks-utils.mjs'
import { TaskFunctions } from '../benchmarks-types.mjs'
data = data || {}
data.function = data.function || TaskFunctions.jsonIntegerSerialization
const res = executeTaskFunction(data)
- debug === true && console.debug('This is the main thread ' + isMaster)
+ debug === true && console.debug(`This is the main thread ${isPrimary}`)
return res
}
data = data || {}
data.function = data.function || TaskFunctions.jsonIntegerSerialization
const res = executeTaskFunction(data)
- debug === true && console.debug('This is the main thread ' + isMainThread)
+ debug === true && console.debug(`This is the main thread ${isMainThread}`)
return res
}
.then(() => {
resolved++
if (resolved === iterations) {
- console.info('Time taken is ' + (performance.now() - start))
- console.info('The pool was full for ' + poolFull + ' times')
- console.info('The pool was ready for ' + poolReady + ' times')
- return console.info('The pool was busy for ' + poolBusy + ' times')
+ console.info(`Time taken is ${performance.now() - start}`)
+ console.info(`The pool was full for ${poolFull} times`)
+ console.info(`The pool was ready for ${poolReady} times`)
+ return console.info(`The pool was busy for ${poolBusy} times`)
}
return null
})
.then(() => {
resolved++
if (resolved === iterations) {
- console.info('Time taken is ' + (performance.now() - start))
- console.info('The pool was ready for ' + poolReady + ' times')
- return console.info('The pool was busy for ' + poolBusy + ' times')
+ console.info(`Time taken is ${performance.now() - start}`)
+ console.info(`The pool was ready for ${poolReady} times`)
+ return console.info(`The pool was busy for ${poolBusy} times`)
}
return null
})
function fn0 (data) {
console.info('Executing function 0')
- return { data: 'fn0 your input text was' + data.text }
+ return { data: `fn0 your input text was ${data.text}` }
}
function fn1 (data) {
console.info('Executing function 1')
- return { data: 'fn1 your input text was' + data.text }
+ return { data: `fn1 your input text was ${data.text}` }
}
module.exports = new ThreadWorker({ fn0, fn1 })
}
JSON.stringify(o)
}
- debug === true && console.info('This is the main thread ' + isMainThread)
+ debug === true && console.info(`This is the main thread ${isMainThread}`)
return { ok: 1 }
}
* @param message - The received message.
*/
protected messageListener (message: MessageValue<Data>): void {
- if (this.isMain) {
- throw new Error('Cannot handle message to worker in main worker')
- }
this.checkMessageWorkerId(message)
if (message.statistics != null) {
// Statistics message received