Skip to content

Commit

Permalink
Revert "Show Median, P90, and P95 line in MermaidXYChart"
Browse files Browse the repository at this point in the history
This reverts commit c55d0dc.
  • Loading branch information
yykamei committed Apr 3, 2024
1 parent c55d0dc commit a6a548a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 62 deletions.
21 changes: 0 additions & 21 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29457,13 +29457,11 @@ class MermaidXYChart {
seconds.unshift(mean);
}
const status = this.input.status ? ` for status=${this.input.status}` : "";
const { p50, p90, p95 } = this.getPercentiles();
return `
\`\`\`mermaid
---
config:
xyChart:
width: 900
xAxis:
labelPadding: 16
labelFontSize: 8
Expand All @@ -29475,28 +29473,9 @@ xychart-beta
x-axis [${xAxis.join(",")}]
y-axis "Duration (in seconds)"
bar [${seconds.join(",")}]
line [${seconds.map(() => p50).join(",")}]
line [${seconds.map(() => p90).join(",")}]
line [${seconds.map(() => p95).join(",")}]
\`\`\`
`;
}
getPercentiles() {
const durations = this.runs
.filter((run) => !run.isOutlier)
.map((run) => run.duration.toSeconds())
.sort((a, b) => a - b);
const percentile = (p) => {
const index = Math.floor(p * durations.length);
// @ts-ignore
return durations[index];
};
return {
p50: percentile(0.5),
p90: percentile(0.9),
p95: percentile(0.95),
};
}
}

;// CONCATENATED MODULE: ./src/main.ts
Expand Down
29 changes: 0 additions & 29 deletions src/MermaidXYChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import type { GitHubWorkflow } from "./GitHubWorkflow";
import type { GitHubWorkflowRun } from "./GitHubWorkflowRun";
import type { Input } from "./Input";

type Percentiles = {
readonly p50: number;
readonly p90: number;
readonly p95: number;
};

export class MermaidXYChart {
constructor(
private readonly workflow: GitHubWorkflow,
Expand Down Expand Up @@ -44,7 +38,6 @@ export class MermaidXYChart {
seconds.unshift(mean);
}
const status = this.input.status ? ` for status=${this.input.status}` : "";
const { p50, p90, p95 } = this.getPercentiles();
return `
\`\`\`mermaid
---
Expand All @@ -62,29 +55,7 @@ xychart-beta
x-axis [${xAxis.join(",")}]
y-axis "Duration (in seconds)"
bar [${seconds.join(",")}]
line [${seconds.map(() => p50).join(",")}]
line [${seconds.map(() => p90).join(",")}]
line [${seconds.map(() => p95).join(",")}]
\`\`\`
`;
}

private getPercentiles(): Percentiles {
const durations = this.runs
.filter((run) => !run.isOutlier)
.map((run) => run.duration.toSeconds())
.sort((a, b) => a - b);

const percentile = (p: number): number => {
const index = Math.floor(p * durations.length);
// @ts-ignore
return durations[index];
};

return {
p50: percentile(0.5),
p90: percentile(0.9),
p95: percentile(0.95),
};
}
}
6 changes: 0 additions & 6 deletions tests/GitHubIssueContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ xychart-beta
x-axis ["Feb 27"]
y-axis "Duration (in seconds)"
bar [4]
line [4]
line [4]
line [4]
\`\`\`
Expand All @@ -99,9 +96,6 @@ xychart-beta
x-axis ["Mar 27"]
y-axis "Duration (in seconds)"
bar [2]
line [2]
line [2]
line [2]
\`\`\`
`);
});
Expand Down
6 changes: 0 additions & 6 deletions tests/MermaidXYChart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ xychart-beta
x-axis ["Feb 19","Feb 20","Feb 21","Feb 22","Feb 23","Feb 24","Feb 25","Feb 26","Feb 27"]
y-axis "Duration (in seconds)"
bar [424,942,971,1055,911,734,684,658,815]
line [815,815,815,815,815,815,815,815,815]
line [1055,1055,1055,1055,1055,1055,1055,1055,1055]
line [1055,1055,1055,1055,1055,1055,1055,1055,1055]
\`\`\`
`);
});
Expand Down Expand Up @@ -151,9 +148,6 @@ xychart-beta
x-axis ["Feb 19"]
y-axis "Duration (in seconds)"
bar [521]
line [521]
line [521]
line [521]
\`\`\`
`);
});
Expand Down

0 comments on commit a6a548a

Please sign in to comment.