2 MeasurementStatisticsRequirements
,
3 WorkerChoiceStrategyOptions
4 } from
'./pools/selection-strategies/selection-strategies-types'
7 * An intentional empty function.
9 export const EMPTY_FUNCTION
: () => void = Object.freeze(() => {
10 /* Intentionally empty */
14 * Default worker choice strategy options.
16 export const DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
: WorkerChoiceStrategyOptions
=
18 runTime
: { median
: false },
19 waitTime
: { median
: false },
20 elu
: { median
: false }
24 * Default measurement statistics requirements.
26 export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS
: MeasurementStatisticsRequirements
=
34 * Compute the median of the given data set.
36 * @param dataSet - Data set.
37 * @returns The median of the given data set.
39 export const median
= (dataSet
: number[]): number => {
40 if (Array.isArray(dataSet
) && dataSet
.length
=== 0) {
43 if (Array.isArray(dataSet
) && dataSet
.length
=== 1) {
46 const sortedDataSet
= dataSet
.slice().sort((a
, b
) => a
- b
)
48 (sortedDataSet
[(sortedDataSet
.length
- 1) >> 1] +
49 sortedDataSet
[sortedDataSet
.length
>> 1]) /
55 * Is the given object a plain object?
57 * @param obj - The object to check.
58 * @returns `true` if the given object is a plain object, `false` otherwise.
60 export const isPlainObject
= (obj
: unknown
): boolean =>
61 typeof obj
=== 'object' &&
63 obj
?.constructor
=== Object &&
64 Object.prototype
.toString
.call(obj
) === '[object Object]'