import { parentPort } from 'node:worker_threads'
import { secondsToMilliseconds } from 'date-fns'
+import { is, mean, median } from 'rambda'
import { BaseError } from '../exception/index.js'
import {
ConfigurationSection,
type IncomingRequestCommand,
type LogConfiguration,
+ MapStringifyFormat,
MessageType,
type RequestCommand,
type Statistics,
type TimestampedData
} from '../types/index.js'
import {
- average,
buildPerformanceStatisticsMessage,
CircularArray,
Configuration,
extractTimeSeriesValues,
formatDurationSeconds,
generateUUID,
- JSONStringifyWithMapSupport,
+ JSONStringify,
logger,
logPrefix,
max,
- median,
min,
nthPercentile,
stdDeviation
try {
performance.measure(name, markId)
} catch (error) {
- if (error instanceof Error && error.message.includes('performance mark has not been set')) {
+ if (is(Error, error) && error.message.includes('performance mark has not been set')) {
/* Ignore */
} else {
throw error
logger.info(this.logPrefix(), {
...this.statistics,
statisticsData: JSON.parse(
- JSONStringifyWithMapSupport(this.statistics.statisticsData)
+ JSONStringify(this.statistics.statisticsData, undefined, MapStringifyFormat.object)
) as Map<string | RequestCommand | IncomingRequestCommand, StatisticsData>
})
}
this.statistics.statisticsData.get(entry.name)!.measurementTimeSeries!
)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.statistics.statisticsData.get(entry.name)!.avgTimeMeasurement =
- average(timeMeasurementValues)
+ this.statistics.statisticsData.get(entry.name)!.avgTimeMeasurement = mean(timeMeasurementValues)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.statistics.statisticsData.get(entry.name)!.medTimeMeasurement =
median(timeMeasurementValues)