mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
Add summary
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import { globby } from 'globby';
|
import { globby } from 'globby';
|
||||||
import { markdownTable } from 'markdown-table';
|
|
||||||
|
|
||||||
interface RunTimes {
|
interface RunTimes {
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
@@ -56,6 +55,9 @@ const main = async () => {
|
|||||||
const newStats = await readStats(`${base}/runtimes/head/**/*.csv`);
|
const newStats = await readStats(`${base}/runtimes/head/**/*.csv`);
|
||||||
const fullData: string[][] = [];
|
const fullData: string[][] = [];
|
||||||
const changed: string[][] = [];
|
const changed: string[][] = [];
|
||||||
|
let oldRuntimeSum = 0;
|
||||||
|
let newRuntimeSum = 0;
|
||||||
|
let testCount = 0;
|
||||||
for (const [fileName, runtimes] of Object.entries(newStats)) {
|
for (const [fileName, runtimes] of Object.entries(newStats)) {
|
||||||
const oldStat = oldStats[fileName];
|
const oldStat = oldStats[fileName];
|
||||||
if (!oldStat) {
|
if (!oldStat) {
|
||||||
@@ -66,6 +68,9 @@ const main = async () => {
|
|||||||
if (!oldTimeTaken) {
|
if (!oldTimeTaken) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
oldRuntimeSum += oldTimeTaken;
|
||||||
|
newRuntimeSum += timeTaken;
|
||||||
|
testCount++;
|
||||||
const delta = timeTaken - oldTimeTaken;
|
const delta = timeTaken - oldTimeTaken;
|
||||||
|
|
||||||
const { change, crossedThreshold } = percentageDifference(oldTimeTaken, timeTaken);
|
const { change, crossedThreshold } = percentageDifference(oldTimeTaken, timeTaken);
|
||||||
@@ -81,8 +86,22 @@ const main = async () => {
|
|||||||
fullData.push(out);
|
fullData.push(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const oldAverage = oldRuntimeSum / testCount;
|
||||||
|
const newAverage = newRuntimeSum / testCount;
|
||||||
|
const { change, crossedThreshold } = percentageDifference(oldAverage, newAverage);
|
||||||
|
|
||||||
const headers = ['File', 'Test', 'Time Old/New', 'Change (%)'];
|
const headers = ['File', 'Test', 'Time Old/New', 'Change (%)'];
|
||||||
console.log(markdownTable([headers, ...changed]));
|
console.log(`## Runtime Changes
|
||||||
|
Old runtime average: ${oldAverage.toFixed(2)}ms
|
||||||
|
New runtime average: ${newAverage.toFixed(2)}ms
|
||||||
|
Change: ${change} ${crossedThreshold ? '⚠️' : ''}
|
||||||
|
`);
|
||||||
|
console.log(`
|
||||||
|
<details>
|
||||||
|
<summary>Changed tests</summary>
|
||||||
|
${htmlTable([headers, ...changed])}
|
||||||
|
</details>
|
||||||
|
`);
|
||||||
console.log(`
|
console.log(`
|
||||||
<details>
|
<details>
|
||||||
<summary>Full Data</summary>
|
<summary>Full Data</summary>
|
||||||
|
Reference in New Issue
Block a user