UNPKG

playwright-performance

Version:

Playwright plugin for analyzing test flow performance

27 lines (26 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Calculator { daysBetweenDates(latestTime, earlierTime) { const millisecondsPerDay = 24 * 60 * 60 * 1000; const diffInMilliseconds = Math.abs(latestTime - earlierTime); return (diffInMilliseconds / millisecondsPerDay); } getAverageAndStandardDeviation(durationList) { const mean = this.getAverageTimeSpan(durationList); let sos = 0; let sem = 0; // calculate sem if (durationList.length > 1) { durationList.forEach(d => sos += Math.pow(d - mean, 2)); const std = Math.sqrt(sos / (durationList.length - 1)); sem = std / Math.sqrt(durationList.length); } return [Math.round(mean), Math.round(sem)]; } getAverageTimeSpan(durationList) { const result = durationList.reduce((a, b) => a + b, 0) / durationList.length; return Math.round(result); } } exports.default = new Calculator();