ci: get rid of codspeed

This commit is contained in:
Abdullah Atta
2024-11-13 15:44:50 +05:00
committed by Abdullah Atta
parent 6a261d284f
commit a3e7d5bd84
4 changed files with 48 additions and 184 deletions

View File

@@ -39,8 +39,6 @@ jobs:
working-directory: apps/web
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: node __bench__/app.bench.mjs
working-directory: apps/web
token: ${{ secrets.CODSPEED_TOKEN }}
id: benchmark
run: node __bench__/app.bench.mjs
working-directory: apps/web

View File

@@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { chromium } from "playwright";
import { Bench } from "tinybench";
import { withCodSpeed } from "@codspeed/tinybench-plugin";
import { bench, run, summary } from "mitata";
import { spawn } from "child_process";
const TESTS = [
@@ -72,66 +71,50 @@ const server = await startServer();
const browser = await chromium.launch();
for (const testCase of TESTS) {
/**
* @type {import("playwright").BrowserContext}
*/
let context;
/**
* @type {import("playwright").Page}
*/
let page;
summary(() => {
bench(testCase.name, async function* () {
const context = await browser.newContext({
baseURL: "http://localhost:3000"
});
await context.addInitScript({
content: `window.localStorage.setItem("skipInitiation", "true");
const bench = withCodSpeed(
new Bench({
time: 5000,
async setup() {
context = await browser.newContext({
baseURL: "http://localhost:3000"
const observer = new PerformanceObserver((list, observer) => {
list.getEntries().forEach((entry) => {
if (entry.entryType === "mark" && entry.name === "${testCase.end}") {
observer.disconnect();
console.log(
"ended: ${testCase.name}",
performance.measure(
"${testCase.end}",
"${testCase.start}",
"${testCase.end}"
).duration
);
window.close();
}
});
await context.addInitScript({
content: `window.localStorage.setItem("skipInitiation", "true");
});
observer.observe({ entryTypes: ["mark"] });`
});
const page = await context.newPage();
const observer = new PerformanceObserver((list, observer) => {
list.getEntries().forEach((entry) => {
if (entry.entryType === "mark" && entry.name === "${testCase.end}") {
observer.disconnect();
console.log(
"ended: ${testCase.name}",
performance.measure(
"${testCase.end}",
"${testCase.start}",
"${testCase.end}"
).duration
);
window.close();
}
});
yield async () => {
await page.goto(testCase.route || "/");
await page.waitForEvent("console", {
predicate(consoleMessage) {
return consoleMessage.text().startsWith(`ended: ${testCase.name}`);
}
});
observer.observe({ entryTypes: ["mark"] });`
});
page = await context.newPage();
},
async teardown() {
await context.close();
}
})
);
};
bench.add(testCase.name, async () => {
await page.goto(testCase.route || "/");
await page.waitForEvent("console", {
predicate(consoleMessage) {
return consoleMessage.text().startsWith(`ended: ${testCase.name}`);
}
await context.close();
});
});
await bench.warmup();
await bench.run();
console.table(bench.table());
}
await run();
await browser.close();
server.stdout.destroy();

View File

@@ -88,7 +88,6 @@
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@codspeed/tinybench-plugin": "^3.1.1",
"@playwright/test": "^1.48.2",
"@swc/core": "^1.5.24",
"@swc/plugin-react-remove-properties": "^2.0.4",
@@ -116,6 +115,7 @@
"happy-dom": "^8.9.0",
"ip": "^1.1.8",
"lorem-ipsum": "^2.0.4",
"mitata": "^1.0.10",
"otplib": "^12.0.1",
"rollup": "^4.18.0",
"rollup-plugin-visualizer": "^5.12.0",
@@ -40528,33 +40528,6 @@
"pnpm": ">=5"
}
},
"node_modules/@codspeed/core": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@codspeed/core/-/core-3.1.1.tgz",
"integrity": "sha512-ONhERVDAtkm0nc+FYPivDozoMOlNUP2BWRBFDJYATGA18Iap5Kd2mZ1/Lwz54RB5+g+3YDOpsvotHa4hd3Q+7Q==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"axios": "^1.4.0",
"find-up": "^6.3.0",
"form-data": "^4.0.0",
"node-gyp-build": "^4.6.0"
}
},
"node_modules/@codspeed/tinybench-plugin": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@codspeed/tinybench-plugin/-/tinybench-plugin-3.1.1.tgz",
"integrity": "sha512-LVF4End0kDU9V7CzuwAcmngSPJNnpduPnr+csOKvcG++FsYwfUuBJ1rvLPtv6yTkvxpUmUEsj6VA7/AEIBGZVw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@codspeed/core": "^3.1.1",
"stack-trace": "1.0.0-pre2"
},
"peerDependencies": {
"tinybench": "^2.3.0"
}
},
"node_modules/@dnd-kit/accessibility": {
"version": "3.1.0",
"license": "MIT",
@@ -44767,23 +44740,6 @@
"version": "1.1.0",
"license": "MIT"
},
"node_modules/find-up": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz",
"integrity": "sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==",
"dev": true,
"license": "MIT",
"dependencies": {
"locate-path": "^7.1.0",
"path-exists": "^5.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/follow-redirects": {
"version": "1.15.3",
"funding": [
@@ -46274,22 +46230,6 @@
"url": "https://github.com/sponsors/antfu"
}
},
"node_modules/locate-path": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz",
"integrity": "sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-locate": "^6.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"license": "MIT"
@@ -47358,6 +47298,13 @@
"license": "ISC",
"optional": true
},
"node_modules/mitata": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/mitata/-/mitata-1.0.10.tgz",
"integrity": "sha512-pn21sHg5+AiTqj7z7aCeNlkEXMYhAykl1zbGqp1sbTJKRe8lhNokoyubLmvwbY5sWb8B+VDQByn3UyRmdBDQ1w==",
"dev": true,
"license": "MIT"
},
"node_modules/mkdirp": {
"version": "1.0.4",
"license": "MIT",
@@ -47518,18 +47465,6 @@
}
}
},
"node_modules/node-gyp-build": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.3.tgz",
"integrity": "sha512-EMS95CMJzdoSKoIiXo8pxKoL8DYxwIZXYlLmgPb8KUv794abpnLK6ynsCAWNliOjREKruYKdzbh76HHYUHX7nw==",
"dev": true,
"license": "MIT",
"bin": {
"node-gyp-build": "bin.js",
"node-gyp-build-optional": "optional.js",
"node-gyp-build-test": "build-test.js"
}
},
"node_modules/node-releases": {
"version": "2.0.18",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz",
@@ -47729,38 +47664,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz",
"integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-limit": "^4.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate/node_modules/p-limit": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz",
"integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"yocto-queue": "^1.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/parent-module": {
"version": "1.0.1",
"license": "MIT",
@@ -47791,16 +47694,6 @@
"version": "6.0.1",
"license": "MIT"
},
"node_modules/path-exists": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz",
"integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"devOptional": true,
@@ -49102,16 +48995,6 @@
"version": "1.0.3",
"license": "BSD-3-Clause"
},
"node_modules/stack-trace": {
"version": "1.0.0-pre2",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-1.0.0-pre2.tgz",
"integrity": "sha512-2ztBJRek8IVofG9DBJqdy2N5kulaacX30Nz7xmkYF6ale9WBVmIy6mFBchvGX7Vx/MyjBhx+Rcxqrj+dbOnQ6A==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=16"
}
},
"node_modules/stackback": {
"version": "0.0.2",
"dev": true,

View File

@@ -86,7 +86,6 @@
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@codspeed/tinybench-plugin": "^3.1.1",
"@playwright/test": "^1.48.2",
"@swc/core": "^1.5.24",
"@swc/plugin-react-remove-properties": "^2.0.4",
@@ -114,6 +113,7 @@
"happy-dom": "^8.9.0",
"ip": "^1.1.8",
"lorem-ipsum": "^2.0.4",
"mitata": "^1.0.10",
"otplib": "^12.0.1",
"rollup": "^4.18.0",
"rollup-plugin-visualizer": "^5.12.0",