-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(report) : add statistics in averaged summary (#178)
* refactor: group round function, add default parameter to roundToDecimal * feat: add getStandardDeviation * feat: add getMinMax * refactor: splitting reporting.ts by stat * feat: dedicated file, add function getRamStats * feat: dedicated file, add getHighCpuStats * feat: dedicated file, add getCpuStats * feat: dedicated file, add getFpsStats * feat: dedicated file, add getRuntimeStats * (KO) chore: update imports * feat: Report has public function getStats * feat: to display stats in averaged summary * feat: to pass SummaryStats * feat: display stats only when average is displayed * fix(HighCpu): should use measure as averageTotalHighCpu * snapshot: changes since we use lodash round function now * feat(HighCpu): add getStatsByThread * feat(HighCpu): display stats by thread
- Loading branch information
1 parent
e4c9f40
commit d718057
Showing
20 changed files
with
2,214 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export * from "./reporting/averageIterations"; | ||
export * from "./reporting/getScore"; | ||
export * from "./reporting/reporting"; | ||
export * from "./reporting/Report"; | ||
export * from "./utils/sanitizeProcessName"; | ||
export * from "./utils/roundToDecimal"; | ||
export * from "./utils/round"; | ||
export * from "./reporting/cpu"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Measure, TestCaseIterationResult } from "@perf-profiler/types"; | ||
import _, { round } from "lodash"; | ||
import { getMinMax } from "../utils/getMinMax"; | ||
import { getStandardDeviation } from "../utils/getStandardDeviation"; | ||
import { roundToDecimal } from "../utils/round"; | ||
|
||
const _getAverageCpuUsagePerProcess = (measures: Measure[]) => | ||
_(measures) | ||
.map((measure) => measure.cpu) | ||
.map(({ perName }) => | ||
Object.keys(perName).map((processName) => ({ | ||
processName, | ||
cpuUsage: perName[processName], | ||
})) | ||
) | ||
.flatten() | ||
.groupBy((measure) => measure.processName) | ||
.map((measure, processName) => ({ | ||
processName, | ||
cpuUsage: _.sumBy(measure, (measure) => measure.cpuUsage) / measures.length, | ||
})) | ||
.orderBy((measure) => measure.cpuUsage, "desc") | ||
.value(); | ||
|
||
export const getAverageCpuUsagePerProcess = (measures: Measure[]) => | ||
_getAverageCpuUsagePerProcess(measures).map((measure) => ({ | ||
...measure, | ||
cpuUsage: round(measure.cpuUsage, 1), | ||
})); | ||
|
||
export const getAverageCpuUsage = (measures: Measure[]) => | ||
_getAverageCpuUsagePerProcess(measures).reduce<number>((sum, { cpuUsage }) => sum + cpuUsage, 0); | ||
|
||
export const getStandardDeviationCPU = ( | ||
iterations: TestCaseIterationResult[], | ||
averageCpu: number | ||
): { | ||
deviation: number; | ||
deviationRange: [number, number]; | ||
} => { | ||
const averageCpuUsages = iterations.map((iteration) => getAverageCpuUsage(iteration.measures)); | ||
return getStandardDeviation({ | ||
values: averageCpuUsages, | ||
average: averageCpu, | ||
}); | ||
}; | ||
|
||
export const getMinMaxCPU = (iterations: TestCaseIterationResult[]): [number, number] => { | ||
const averageCpuUsages = iterations.map((iteration) => getAverageCpuUsage(iteration.measures)); | ||
return getMinMax(averageCpuUsages); | ||
}; | ||
|
||
export const getCpuStats = (iterations: TestCaseIterationResult[], averageCpu: number) => { | ||
const standardDeviation = getStandardDeviationCPU(iterations, averageCpu); | ||
return { | ||
minMaxRange: getMinMaxCPU(iterations), | ||
deviationRange: standardDeviation.deviationRange, | ||
variationCoefficient: roundToDecimal((standardDeviation.deviation / averageCpu) * 100), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Measure, TestCaseIterationResult } from "@perf-profiler/types"; | ||
import { getMinMax } from "../utils/getMinMax"; | ||
import { getStandardDeviation } from "../utils/getStandardDeviation"; | ||
import { roundToDecimal } from "../utils/round"; | ||
import { average } from "./averageIterations"; | ||
|
||
export const getAverageFPSUsage = (measures: Measure[]) => | ||
average(measures.map((measure) => measure.fps)); | ||
|
||
export const getStandardDeviationFPS = ( | ||
iterations: TestCaseIterationResult[], | ||
averageFps: number | ||
) => { | ||
const averageFpsUsages: number[] = []; | ||
iterations.forEach((iteration) => { | ||
const value = getAverageFPSUsage(iteration.measures); | ||
value && averageFpsUsages.push(value); | ||
}); | ||
return getStandardDeviation({ values: averageFpsUsages, average: averageFps }); | ||
}; | ||
|
||
const getMinMaxFPS = (iterations: TestCaseIterationResult[]): [number, number] => { | ||
const averageFpsUsages: number[] = []; | ||
iterations.forEach((iteration) => { | ||
const value = getAverageFPSUsage(iteration.measures); | ||
value && averageFpsUsages.push(value); | ||
}); | ||
return getMinMax(averageFpsUsages); | ||
}; | ||
|
||
export const getFpsStats = (iterations: TestCaseIterationResult[], averageFps?: number) => { | ||
if (!averageFps) return undefined; | ||
|
||
const standardDeviation = getStandardDeviationFPS(iterations, averageFps); | ||
return { | ||
minMaxRange: getMinMaxFPS(iterations), | ||
deviationRange: standardDeviation.deviationRange, | ||
variationCoefficient: roundToDecimal((standardDeviation.deviation / averageFps) * 100), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { | ||
Measure, | ||
POLLING_INTERVAL, | ||
TestCaseIterationResult, | ||
AveragedTestCaseResult, | ||
} from "@perf-profiler/types"; | ||
import _ from "lodash"; | ||
import { getMinMax } from "../utils/getMinMax"; | ||
import { getStandardDeviation } from "../utils/getStandardDeviation"; | ||
import { roundToDecimal } from "../utils/round"; | ||
|
||
export const getHighCpuUsage = (measures: Measure[], cpuUsageThreshold: number | undefined = 90) => | ||
_(measures) | ||
.map((measure) => measure.cpu) | ||
.map(({ perName }) => | ||
Object.keys(perName).map((processName) => ({ | ||
processName, | ||
cpuUsage: perName[processName], | ||
})) | ||
) | ||
.flatten() | ||
.filter((measure) => measure.cpuUsage > cpuUsageThreshold) | ||
.groupBy((measure) => measure.processName) | ||
.mapValues((measures) => measures.length * POLLING_INTERVAL) | ||
.value(); | ||
|
||
export const getAverageTotalHighCPUUsage = (highCpuProcesses: { [processName: string]: number }) => | ||
Object.keys(highCpuProcesses).reduce((sum, name) => sum + highCpuProcesses[name], 0); | ||
|
||
const getStatsByThread = (iterations: TestCaseIterationResult[]) => { | ||
const threads: { [threadName: string]: number[] } = {}; | ||
iterations.forEach((iteration) => { | ||
const measure = getHighCpuUsage(iteration.measures); | ||
Object.keys(measure).forEach((threadName) => { | ||
if (!threads[threadName]) { | ||
threads[threadName] = []; | ||
} | ||
threads[threadName].push(measure[threadName]); | ||
}); | ||
}); | ||
|
||
const statsByThread: { | ||
[threadName: string]: { | ||
minMaxRange: [number, number]; | ||
deviationRange: [number, number]; | ||
variationCoefficient: number; | ||
}; | ||
} = {}; | ||
|
||
Object.keys(threads).forEach((threadName) => { | ||
const threadValues = threads[threadName]; | ||
const threadAverage = threadValues.reduce((sum, value) => sum + value, 0) / threadValues.length; | ||
const threadStandardDeviation = getStandardDeviation({ | ||
values: threadValues, | ||
average: threadAverage, | ||
}); | ||
statsByThread[threadName] = { | ||
minMaxRange: getMinMax(threadValues), | ||
deviationRange: threadStandardDeviation.deviationRange, | ||
variationCoefficient: roundToDecimal( | ||
(threadStandardDeviation.deviation / threadAverage) * 100 | ||
), | ||
}; | ||
}); | ||
return statsByThread; | ||
}; | ||
|
||
export const getHighCpuStats = ( | ||
iterations: TestCaseIterationResult[], | ||
averageResultHighCpuUsage: AveragedTestCaseResult["averageHighCpuUsage"] | ||
) => { | ||
const averageTotalHighCpu = getAverageTotalHighCPUUsage(averageResultHighCpuUsage); | ||
|
||
const averageTotalHighCPuUsage = iterations.map((iteration) => | ||
getAverageTotalHighCPUUsage(getHighCpuUsage(iteration.measures)) | ||
); | ||
|
||
const standardDeviation = getStandardDeviation({ | ||
values: averageTotalHighCPuUsage, | ||
average: averageTotalHighCpu, | ||
}); | ||
|
||
return { | ||
threads: getStatsByThread(iterations), | ||
minMaxRange: getMinMax(averageTotalHighCPuUsage), | ||
deviationRange: standardDeviation.deviationRange, | ||
variationCoefficient: roundToDecimal((standardDeviation.deviation / averageTotalHighCpu) * 100), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Measure, TestCaseIterationResult } from "@perf-profiler/types"; | ||
import { getMinMax } from "../utils/getMinMax"; | ||
import { getStandardDeviation } from "../utils/getStandardDeviation"; | ||
import { roundToDecimal } from "../utils/round"; | ||
import { average } from "./averageIterations"; | ||
|
||
export const getAverageRAMUsage = (measures: Measure[]) => | ||
average(measures.map((measure) => measure.ram)); | ||
|
||
export const getRamStats = (iterations: TestCaseIterationResult[], averageRam?: number) => { | ||
if (!averageRam) return undefined; | ||
|
||
const values: number[] = []; | ||
iterations.forEach((iteration) => { | ||
const averageRamUsage = getAverageRAMUsage(iteration.measures); | ||
averageRamUsage && values.push(averageRamUsage); | ||
}); | ||
|
||
const standardDeviation = getStandardDeviation({ | ||
values, | ||
average: averageRam, | ||
}); | ||
|
||
return { | ||
minMaxRange: getMinMax(values), | ||
deviationRange: standardDeviation.deviationRange, | ||
variationCoefficient: roundToDecimal((standardDeviation.deviation / averageRam) * 100), | ||
}; | ||
}; |
Oops, something went wrong.