average,
isKillBehavior,
isPlainObject,
+ max,
median,
+ min,
round,
updateMeasurementStatistics
} from '../utils'
.runTime.aggregate && {
runTime: {
minimum: round(
- Math.min(
+ min(
...this.workerNodes.map(
(workerNode) => workerNode.usage.runTime?.minimum ?? Infinity
)
)
),
maximum: round(
- Math.max(
+ max(
...this.workerNodes.map(
(workerNode) => workerNode.usage.runTime?.maximum ?? -Infinity
)
.waitTime.aggregate && {
waitTime: {
minimum: round(
- Math.min(
+ min(
...this.workerNodes.map(
(workerNode) => workerNode.usage.waitTime?.minimum ?? Infinity
)
)
),
maximum: round(
- Math.max(
+ max(
...this.workerNodes.map(
(workerNode) => workerNode.usage.waitTime?.maximum ?? -Infinity
)
return webcrypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000
}
-const min = (a: number, b: number): number => (a < b ? a : b)
-const max = (a: number, b: number): number => (a > b ? a : b)
+export const min = (...args: number[]): number =>
+ args.reduce((minimum, num) => (minimum < num ? minimum : num), Infinity)
+
+export const max = (...args: number[]): number =>
+ args.reduce((maximum, num) => (maximum > num ? maximum : num), -Infinity)
isAsyncFunction,
isKillBehavior,
isPlainObject,
+ max,
median,
+ min,
round,
secureRandom,
sleep,
expect(randomNumber).toBeGreaterThanOrEqual(0)
expect(randomNumber).toBeLessThan(1)
})
+
+ it('Verify min() behavior', () => {
+ expect(min(1, 2)).toBe(1)
+ expect(min(2, 1)).toBe(1)
+ expect(min(1, 1)).toBe(1)
+ })
+
+ it('Verify max() behavior', () => {
+ expect(max(1, 2)).toBe(2)
+ expect(max(2, 1)).toBe(2)
+ expect(max(1, 1)).toBe(1)
+ })
})