Skip to content

Commit

Permalink
refactor: adjust memory statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Aug 20, 2024
1 parent 061dd2a commit 28250ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iperf",
"version": "0.1.0-beta.7",
"version": "0.1.0-beta.8",
"description": "Performance Testing Framework for Front-end Renderers",
"keywords": [
"performance",
Expand Down
14 changes: 13 additions & 1 deletion src/client/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@ export function analyzeTime(values: number[], memories: number[]) {
const variance =
prune.reduce((acc, cur) => acc + (cur - avg) ** 2, 0) / prune.length;

const deltas: number[] = [];
if (memories.length > 1) {
for (let i = 1; i < memories.length; i++) {
const prev = memories[i - 1];
const curr = memories[i];
const delta = curr - prev;
deltas.push(delta);
}
} else {
deltas.push(memories[0] ?? NaN);
}

const memory =
memories.reduce((acc, cur) => acc + cur, 0) / memories.length / 1024 / 1024;
deltas.reduce((acc, cur) => acc + cur, 0) / deltas.length / 1024 / 1024;

return { min, max, median, avg, variance, reliable, memory };
}
Expand Down

0 comments on commit 28250ab

Please sign in to comment.