summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
147be6f)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
### Interleaved weighted round robin
The worker weights are maximum tasks execution time. The rounds are the deduplicated worker weights.
### Interleaved weighted round robin
The worker weights are maximum tasks execution time. The rounds are the deduplicated worker weights.
-During a round, if worker weight is inferior to the current round weight, the next task is assigned to the next worker. Once all workers have been assigned a task, the next round starts.
+During a round, if the worker weight is superior or equal to the current round weight, the task is assigned to the worker. Once all workers weight have been tested, the next round starts.
The default worker weights is the same for each and computed given the CPU cores speed and theirs numbers. So the default 'rounds' consists of a unique worker weight.
## Statistics
The default worker weights is the same for each and computed given the CPU cores speed and theirs numbers. So the default 'rounds' consists of a unique worker weight.
## Statistics
readonly elu?: MeasurementOptions
/**
* Worker weights to use for weighted round robin worker selection strategies.
readonly elu?: MeasurementOptions
/**
* Worker weights to use for weighted round robin worker selection strategies.
- * A weight is the tasks maximum execution in milliseconds for each worker node.
+ * A weight is the tasks maximum execution time in milliseconds for each worker node.
*
* @defaultValue Weights computed automatically given the CPU performance.
*/
*
* @defaultValue Weights computed automatically given the CPU performance.
*/
import * as os from 'node:os'
import * as os from 'node:os'
+import { getRandomValues } from 'node:crypto'
import type {
MeasurementStatisticsRequirements,
WorkerChoiceStrategyOptions
import type {
MeasurementStatisticsRequirements,
WorkerChoiceStrategyOptions
*
* @returns A number in the [0,1[ range
*/
*
* @returns A number in the [0,1[ range
*/
-const secureRandom = (): number => {
- return crypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000
+export const secureRandom = (): number => {
+ return getRandomValues(new Uint32Array(1))[0] / 0x100000000
isPlainObject,
median,
round,
isPlainObject,
median,
round,
updateMeasurementStatistics
} = require('../lib/utils')
const { KillBehaviors } = require('../lib/worker/worker-options')
updateMeasurementStatistics
} = require('../lib/utils')
const { KillBehaviors } = require('../lib/worker/worker-options')
history: new CircularArray(DEFAULT_CIRCULAR_ARRAY_SIZE, 0.001, 0.003)
})
})
history: new CircularArray(DEFAULT_CIRCULAR_ARRAY_SIZE, 0.001, 0.003)
})
})
+
+ it('Verify secureRandom() behavior', () => {
+ const randomNumber = secureRandom()
+ expect(typeof randomNumber === 'number').toBe(true)
+ expect(randomNumber).toBeGreaterThanOrEqual(0)
+ expect(randomNumber).toBeLessThan(1)
+ })