Performance measurement: pnpm perf:measure and the lab helper (phone/desktop, vitals, bytes, queries per render)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 13:51:39 +01:00
co-authored by Claude Opus 5.5
parent ee241deee0
commit f3be77b2bc
5 changed files with 1834 additions and 2 deletions
+753
View File
@@ -0,0 +1,753 @@
{
"client": {
"mobile": {
"home": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 19872,
"image": 9532,
"js": 184428,
"other": 24705
},
"cls": 0.036,
"fcp": 816,
"inp": 40,
"interaction": "PL",
"lcp": 816,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2440,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 26,
"scriptMs": 76,
"status": 200,
"tbt": 6,
"thirdParty": [],
"ttfb": 151,
"url": "/pl",
"runs": 3
},
"page": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 17099,
"image": 8451,
"js": 184428,
"other": 13035
},
"cls": 0,
"fcp": 800,
"inp": 32,
"interaction": "PL",
"lcp": 800,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2451,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 21,
"scriptMs": 82,
"status": 200,
"tbt": 7,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/o-nas",
"runs": 3
},
"archive": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16468,
"image": 5316,
"js": 184428,
"other": 18548
},
"cls": 0,
"fcp": 796,
"inp": 32,
"interaction": "PL",
"lcp": 796,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2443,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 22,
"scriptMs": 74,
"status": 200,
"tbt": 6,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/blog",
"runs": 3
},
"post": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 17059,
"image": 5316,
"js": 184428,
"other": 13035
},
"cls": 0,
"fcp": 796,
"inp": 32,
"interaction": "PL",
"lcp": 796,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2450,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 21,
"scriptMs": 77,
"status": 200,
"tbt": 13,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/blog/zanim-kupisz-dzialke",
"runs": 3
},
"caseStudy": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16558,
"image": 4372,
"js": 184428,
"other": 13035
},
"cls": 0,
"fcp": 816,
"inp": 32,
"interaction": "PL",
"lcp": 816,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2436,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 20,
"scriptMs": 82,
"status": 200,
"tbt": 12,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/realizacje/dom-pod-lasem",
"runs": 3
},
"form": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16307,
"image": 0,
"js": 184428,
"other": 13035
},
"cls": 0,
"fcp": 808,
"inp": 32,
"interaction": "PL",
"lcp": 808,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2401,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 18,
"scriptMs": 77,
"status": 200,
"tbt": 7,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/wycena",
"runs": 3
},
"showcase": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 36928,
"image": 2016,
"js": 212731,
"other": 24821
},
"cls": 0,
"fcp": 836,
"inp": 40,
"interaction": "PL",
"lcp": 836,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2424,
"profile": "mobile",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 25,
"scriptMs": 148,
"status": 200,
"tbt": 9,
"thirdParty": [
"https://challenges.cloudflare.com"
],
"ttfb": 151,
"url": "/pl/bloki",
"runs": 3
},
"notFound": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 7733,
"image": 0,
"js": 184428,
"other": 68188
},
"cls": 0.319,
"fcp": 2372,
"inp": 32,
"interaction": "PL",
"lcp": 2372,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2531,
"profile": "mobile",
"renderBlocking": [],
"requests": 27,
"scriptMs": 124,
"status": 404,
"tbt": 0,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/nie-ma-takiej-strony",
"runs": 3
}
},
"desktop": {
"home": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 19872,
"image": 9274,
"js": 184428,
"other": 71365
},
"cls": 0.001,
"fcp": 292,
"inp": 32,
"interaction": "PL",
"lcp": 292,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 454,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 33,
"scriptMs": 26,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl",
"runs": 3
},
"page": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 17099,
"image": 10676,
"js": 184428,
"other": 47905
},
"cls": 0,
"fcp": 284,
"inp": 32,
"interaction": "PL",
"lcp": 284,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "/_next/image?url=http%3A%2F%2Flocalhost%3A3370%2Fapi%2Fmedia%2Ffile%2Flibrary.webp&w=750&q=75",
"tag": "img"
},
"load": 456,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 28,
"scriptMs": 17,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/o-nas",
"runs": 3
},
"archive": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16468,
"image": 4809,
"js": 184428,
"other": 64679
},
"cls": 0,
"fcp": 284,
"inp": 32,
"interaction": "PL",
"lcp": 284,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 459,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 30,
"scriptMs": 17,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/blog",
"runs": 3
},
"post": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 17059,
"image": 4809,
"js": 184428,
"other": 47905
},
"cls": 0,
"fcp": 284,
"inp": 40,
"interaction": "PL",
"lcp": 284,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 459,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 27,
"scriptMs": 18,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/blog/zanim-kupisz-dzialke",
"runs": 3
},
"caseStudy": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16558,
"image": 9278,
"js": 184428,
"other": 47905
},
"cls": 0,
"fcp": 300,
"inp": 40,
"interaction": "PL",
"lcp": 300,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 460,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 28,
"scriptMs": 19,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/realizacje/dom-pod-lasem",
"runs": 3
},
"form": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 16307,
"image": 0,
"js": 184428,
"other": 47905
},
"cls": 0,
"fcp": 284,
"inp": 40,
"interaction": "PL",
"lcp": 284,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 454,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 24,
"scriptMs": 18,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/wycena",
"runs": 3
},
"showcase": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 36928,
"image": 5263,
"js": 212674,
"other": 47905
},
"cls": 0,
"fcp": 296,
"inp": 40,
"interaction": "PL",
"lcp": 296,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 458,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/05jza-3-ce5bf.css"
],
"requests": 30,
"scriptMs": 41,
"status": 200,
"tbt": 0,
"thirdParty": [
"https://challenges.cloudflare.com"
],
"ttfb": 41,
"url": "/pl/bloki",
"runs": 3
},
"notFound": {
"bytes": {
"css": 12004,
"font": 209501,
"html": 7733,
"image": 0,
"js": 184428,
"other": 84492
},
"cls": 0,
"fcp": 516,
"inp": 40,
"interaction": "PL",
"lcp": 576,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 513,
"profile": "desktop",
"renderBlocking": [],
"requests": 31,
"scriptMs": 29,
"status": 404,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/nie-ma-takiej-strony",
"runs": 3
}
},
"admin": {
"bytes": {
"css": 98914,
"font": 0,
"html": 23023,
"image": 0,
"js": 876243,
"other": 1690
},
"cls": 0,
"fcp": 1052,
"inp": null,
"interaction": null,
"lcp": 1052,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "a"
},
"load": 975,
"profile": "desktop",
"renderBlocking": [
"/_next/static/chunks/1l9apu4iesvci.css",
"/_next/static/chunks/3c_6gydv624zb.css",
"/_next/static/chunks/3ebvnk7qs9043.css",
"/_next/static/chunks/2h0ajyj_brp--.css",
"/_next/static/chunks/3k6de-uhqm-in.css",
"/_next/static/chunks/1z_mbvpkjhpd5.css",
"/_next/static/chunks/2do7kfo662xwp.css"
],
"requests": 23,
"scriptMs": 410,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 90,
"url": "/admin/login",
"runs": 3
}
},
"date": "2026-12-01T12:14:21.329Z",
"label": "turbopack-before",
"method": "scripts/perf-measure.mjs + reference/e2e/perf-lab.mjs",
"runs": 3,
"server": {
"coldStartHealthMs": 1455,
"coldStartFirstPageMs": 1478,
"firstPageMs": 22,
"ttfb_home": {
"median": 3.9,
"p95": 6.2
},
"ttfb_md": {
"median": 21,
"p95": 42.4
},
"ttfb_sitemap": {
"median": 0.9,
"p95": 1.5
},
"ttfb_llms": {
"median": 28.5,
"p95": 34
},
"render": {
"home": {
"medianMs": 56.6,
"queries": 43,
"queryMs": 0,
"byCollection": {
"globals": 39,
"media": 24,
"pages": 57,
"forms": 9
}
},
"page": {
"medianMs": 40.5,
"queries": 34,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 48,
"media": 12,
"forms": 6
}
},
"archive": {
"medianMs": 31.7,
"queries": 34,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 45,
"media": 9,
"forms": 6,
"posts": 6
}
},
"post": {
"medianMs": 40.9,
"queries": 41,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 39,
"media": 15,
"posts": 27,
"forms": 6
}
},
"caseStudy": {
"medianMs": 32.5,
"queries": 37,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 36,
"media": 12,
"casestudies": 21,
"forms": 6
}
},
"form": {
"medianMs": 28.2,
"queries": 30,
"queryMs": 0,
"byCollection": {
"globals": 36,
"media": 6,
"pages": 42,
"forms": 6
}
},
"showcase": {
"medianMs": 72.7,
"queries": 42,
"queryMs": 0,
"byCollection": {
"globals": 30,
"pages": 57,
"media": 21,
"forms": 12,
"posts": 6
}
},
"notFound": {
"medianMs": 26.6,
"queries": 25,
"queryMs": 0,
"byCollection": {
"globals": 33,
"pages": 33,
"media": 9
}
},
"md": {
"medianMs": 29,
"queries": 16,
"queryMs": 0,
"byCollection": {
"globals": 4,
"media": 5,
"pages": 6,
"forms": 1
}
},
"sitemap": {
"medianMs": 2,
"queries": 0,
"queryMs": 0,
"byCollection": {}
},
"llms": {
"medianMs": 33,
"queries": 22,
"queryMs": 0,
"byCollection": {
"globals": 4,
"media": 3,
"pages": 7,
"posts": 4,
"casestudies": 4
}
},
"llmsFull": {
"medianMs": 55,
"queries": 38,
"queryMs": 0,
"byCollection": {
"globals": 6,
"media": 9,
"pages": 13,
"forms": 2,
"posts": 4,
"casestudies": 4
}
}
},
"rssMiB": 308
}
}
+751
View File
@@ -0,0 +1,751 @@
{
"client": {
"mobile": {
"home": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 19829,
"image": 9532,
"js": 191323,
"other": 24973
},
"cls": 0.036,
"fcp": 800,
"inp": 32,
"interaction": "PL",
"lcp": 800,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2492,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 26,
"scriptMs": 124,
"status": 200,
"tbt": 24,
"thirdParty": [],
"ttfb": 151,
"url": "/pl",
"runs": 3
},
"page": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 17074,
"image": 8451,
"js": 191323,
"other": 13185
},
"cls": 0,
"fcp": 788,
"inp": 40,
"interaction": "PL",
"lcp": 788,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2508,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 21,
"scriptMs": 117,
"status": 200,
"tbt": 22,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/o-nas",
"runs": 3
},
"archive": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16520,
"image": 5316,
"js": 191323,
"other": 18759
},
"cls": 0,
"fcp": 796,
"inp": 32,
"interaction": "PL",
"lcp": 796,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2495,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 22,
"scriptMs": 118,
"status": 200,
"tbt": 22,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/blog",
"runs": 3
},
"post": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 17019,
"image": 5316,
"js": 191323,
"other": 13185
},
"cls": 0,
"fcp": 788,
"inp": 32,
"interaction": "PL",
"lcp": 788,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2502,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 21,
"scriptMs": 122,
"status": 200,
"tbt": 22,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/blog/zanim-kupisz-dzialke",
"runs": 3
},
"caseStudy": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16514,
"image": 4372,
"js": 191323,
"other": 13185
},
"cls": 0,
"fcp": 792,
"inp": 32,
"interaction": "PL",
"lcp": 792,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2487,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 20,
"scriptMs": 121,
"status": 200,
"tbt": 24,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/realizacje/dom-pod-lasem",
"runs": 3
},
"form": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16262,
"image": 0,
"js": 191323,
"other": 13185
},
"cls": 0,
"fcp": 792,
"inp": 32,
"interaction": "PL",
"lcp": 792,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2453,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 18,
"scriptMs": 118,
"status": 200,
"tbt": 23,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/wycena",
"runs": 3
},
"showcase": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 36904,
"image": 2016,
"js": 219569,
"other": 25103
},
"cls": 0,
"fcp": 832,
"inp": 40,
"interaction": "PL",
"lcp": 832,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000'%3",
"tag": "img"
},
"load": 2474,
"profile": "mobile",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 25,
"scriptMs": 185,
"status": 200,
"tbt": 25,
"thirdParty": [
"https://challenges.cloudflare.com"
],
"ttfb": 151,
"url": "/pl/bloki",
"runs": 3
},
"notFound": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 7675,
"image": 0,
"js": 191323,
"other": 68911
},
"cls": 0.319,
"fcp": 2488,
"inp": 32,
"interaction": "PL",
"lcp": 2488,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 2400,
"profile": "mobile",
"renderBlocking": [],
"requests": 27,
"scriptMs": 195,
"status": 404,
"tbt": 0,
"thirdParty": [],
"ttfb": 151,
"url": "/pl/nie-ma-takiej-strony",
"runs": 3
}
},
"desktop": {
"home": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 19829,
"image": 9274,
"js": 191323,
"other": 72045
},
"cls": 0.001,
"fcp": 288,
"inp": 32,
"interaction": "PL",
"lcp": 288,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 471,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 33,
"scriptMs": 40,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl",
"runs": 3
},
"page": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 17074,
"image": 10676,
"js": 191323,
"other": 48398
},
"cls": 0,
"fcp": 316,
"inp": 40,
"interaction": "PL",
"lcp": 316,
"lcpElement": {
"fetchpriority": "high",
"loading": "eager",
"src": "/_next/image?url=http%3A%2F%2Flocalhost%3A3370%2Fapi%2Fmedia%2Ffile%2Flibrary.webp&w=750&q=75",
"tag": "img"
},
"load": 488,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 28,
"scriptMs": 32,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/o-nas",
"runs": 3
},
"archive": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16520,
"image": 4809,
"js": 191323,
"other": 65341
},
"cls": 0,
"fcp": 292,
"inp": 40,
"interaction": "PL",
"lcp": 292,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 472,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 30,
"scriptMs": 34,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/blog",
"runs": 3
},
"post": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 17019,
"image": 4809,
"js": 191323,
"other": 48398
},
"cls": 0,
"fcp": 292,
"inp": 40,
"interaction": "PL",
"lcp": 292,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 471,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 27,
"scriptMs": 33,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/blog/zanim-kupisz-dzialke",
"runs": 3
},
"caseStudy": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16514,
"image": 9278,
"js": 191323,
"other": 48398
},
"cls": 0,
"fcp": 304,
"inp": 40,
"interaction": "PL",
"lcp": 304,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 468,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 28,
"scriptMs": 31,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/realizacje/dom-pod-lasem",
"runs": 3
},
"form": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 16262,
"image": 0,
"js": 191323,
"other": 48398
},
"cls": 0,
"fcp": 284,
"inp": 40,
"interaction": "PL",
"lcp": 284,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 470,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 24,
"scriptMs": 34,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/wycena",
"runs": 3
},
"showcase": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 36904,
"image": 5263,
"js": 219626,
"other": 48398
},
"cls": 0,
"fcp": 300,
"inp": 40,
"interaction": "PL",
"lcp": 300,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "p"
},
"load": 467,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/42cf443dc3526fb0.css"
],
"requests": 30,
"scriptMs": 44,
"status": 200,
"tbt": 0,
"thirdParty": [
"https://challenges.cloudflare.com"
],
"ttfb": 41,
"url": "/pl/bloki",
"runs": 3
},
"notFound": {
"bytes": {
"css": 11023,
"font": 209501,
"html": 7675,
"image": 0,
"js": 191323,
"other": 85467
},
"cls": 0,
"fcp": 516,
"inp": 32,
"interaction": "PL",
"lcp": 580,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "h1"
},
"load": 509,
"profile": "desktop",
"renderBlocking": [],
"requests": 31,
"scriptMs": 44,
"status": 404,
"tbt": 0,
"thirdParty": [],
"ttfb": 41,
"url": "/pl/nie-ma-takiej-strony",
"runs": 3
}
},
"admin": {
"bytes": {
"css": 98168,
"font": 0,
"html": 23080,
"image": 0,
"js": 843253,
"other": 1690
},
"cls": 0,
"fcp": 1044,
"inp": null,
"interaction": null,
"lcp": 1044,
"lcpElement": {
"fetchpriority": null,
"loading": null,
"src": null,
"tag": "a"
},
"load": 963,
"profile": "desktop",
"renderBlocking": [
"/_next/static/css/de3d54fcc6ee5dc6.css",
"/_next/static/css/dc48c3ee3f159f65.css",
"/_next/static/css/c1e0b959dd828ab8.css",
"/_next/static/css/e5d1b6185968e333.css",
"/_next/static/css/4858144d3215dfc6.css"
],
"requests": 20,
"scriptMs": 349,
"status": 200,
"tbt": 0,
"thirdParty": [],
"ttfb": 87,
"url": "/admin/login",
"runs": 3
}
},
"date": "2026-12-01T11:54:21.044Z",
"label": "webpack-before",
"method": "scripts/perf-measure.mjs + reference/e2e/perf-lab.mjs",
"runs": 3,
"server": {
"coldStartHealthMs": 1243,
"coldStartFirstPageMs": 1270,
"firstPageMs": 25,
"ttfb_home": {
"median": 3.5,
"p95": 5.3
},
"ttfb_md": {
"median": 30.4,
"p95": 40.8
},
"ttfb_sitemap": {
"median": 1.1,
"p95": 1.5
},
"ttfb_llms": {
"median": 26.8,
"p95": 39.6
},
"render": {
"home": {
"medianMs": 94.6,
"queries": 43,
"queryMs": 1,
"byCollection": {
"globals": 39,
"media": 24,
"pages": 57,
"forms": 9
}
},
"page": {
"medianMs": 54,
"queries": 34,
"queryMs": 1,
"byCollection": {
"globals": 36,
"pages": 48,
"media": 12,
"forms": 6
}
},
"archive": {
"medianMs": 62.8,
"queries": 34,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 45,
"media": 9,
"forms": 6,
"posts": 6
}
},
"post": {
"medianMs": 61.1,
"queries": 41,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 39,
"media": 15,
"posts": 27,
"forms": 6
}
},
"caseStudy": {
"medianMs": 32.6,
"queries": 37,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 36,
"media": 12,
"casestudies": 21,
"forms": 6
}
},
"form": {
"medianMs": 28.1,
"queries": 30,
"queryMs": 0,
"byCollection": {
"globals": 36,
"pages": 42,
"media": 6,
"forms": 6
}
},
"showcase": {
"medianMs": 68.3,
"queries": 42,
"queryMs": 0,
"byCollection": {
"globals": 30,
"pages": 57,
"media": 21,
"forms": 12,
"posts": 6
}
},
"notFound": {
"medianMs": 28.5,
"queries": 25,
"queryMs": 0,
"byCollection": {
"globals": 33,
"media": 9,
"pages": 33
}
},
"md": {
"medianMs": 24,
"queries": 16,
"queryMs": 0,
"byCollection": {
"globals": 4,
"media": 5,
"pages": 6,
"forms": 1
}
},
"sitemap": {
"medianMs": 2,
"queries": 0,
"queryMs": 0,
"byCollection": {}
},
"llms": {
"medianMs": 36,
"queries": 22,
"queryMs": 0,
"byCollection": {
"globals": 4,
"media": 3,
"pages": 7,
"posts": 4,
"casestudies": 4
}
},
"llmsFull": {
"medianMs": 63,
"queries": 38,
"queryMs": 0,
"byCollection": {
"globals": 6,
"media": 9,
"pages": 13,
"forms": 2,
"posts": 4,
"casestudies": 4
}
}
},
"rssMiB": 340
}
}
+3 -2
View File
@@ -118,15 +118,16 @@
"cookie-db:refresh": "node scripts/refresh-cookie-database.mjs",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
"dev": "next dev dev --turbo",
"e2e:built": "node scripts/e2e-built.mjs",
"legacy:site": "node scripts/legacy-site-check.mjs",
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
"dev:generate-types": "pnpm dev:payload generate:types",
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
"e2e:built": "node scripts/e2e-built.mjs",
"generate:importmap": "pnpm dev:generate-importmap",
"generate:types": "pnpm dev:generate-types",
"legacy:site": "node scripts/legacy-site-check.mjs",
"lint": "eslint ./src ./test",
"lint:fix": "eslint ./src ./test --fix",
"perf:measure": "node scripts/perf-measure.mjs",
"prepare": "pnpm build",
"prepublishOnly": "pnpm clean && pnpm build && pnpm build:starter && pnpm test:int && pnpm starter:gate",
"reference:index": "node scripts/reference-index.mjs",
+165
View File
@@ -0,0 +1,165 @@
/**
* Lab measurements of one page in Chromium (Playwright + the DevTools protocol) — used by `pnpm perf:measure`
* (scripts/perf-measure.mjs, numbers for docs/performance.md) and by the budget gate (e2e/performance.spec.ts).
*
* Profiles follow Lighthouse's defaults so the numbers compare with PageSpeed Insights' lab data:
* - mobile: 412×823 at DPR 1.75, "Slow 4G" (150 ms RTT, 1.6 Mbit/s down, 750 kbit/s up), CPU 4× slower;
* - desktop: 1350×940, 40 ms RTT, 10 Mbit/s, CPU 1×.
* Every run is a fresh browser context (empty HTTP cache, no cookies): a first visit, the worst ordinary case.
*
* What is measured (all from the browser itself, web.dev/articles/vitals):
* ttfb, fcp, lcp (+ the LCP element: tag, src, loading, fetchpriority), cls (session windows, as web-vitals does),
* tbt (sum of long-task time over 50 ms between FCP and the end of the run: the lab stand-in for INP),
* inp (the longest Event Timing entry of one scripted interaction: a click on the page's first visible button),
* scriptMs (CDP Performance.ScriptDuration: parse, compile, run and hydrate), requests, bytes per type
* (transfer size, compressed), renderBlocking (resource timing renderBlockingStatus), thirdParty (requests to
* another origin before any consent is given).
*/
import { chromium } from '@playwright/test'
export const PROFILES = {
desktop: { cpu: 1, network: { downloadThroughput: (10 * 1024 * 1024) / 8, latency: 40, uploadThroughput: (10 * 1024 * 1024) / 8 }, viewport: { deviceScaleFactor: 1, height: 940, isMobile: false, width: 1350 } },
mobile: { cpu: 4, network: { downloadThroughput: (1.6 * 1024 * 1024) / 8, latency: 150, uploadThroughput: (750 * 1024) / 8 }, viewport: { deviceScaleFactor: 1.75, hasTouch: true, height: 823, isMobile: true, width: 412 } },
}
const OBSERVERS = `(() => {
const v = (window.__perf = { cls: 0, events: [], lcp: null, longTasks: [] })
let win = 0, winStart = 0, winLast = 0
new PerformanceObserver((l) => { for (const e of l.getEntries()) {
const el = e.element
v.lcp = { at: e.startTime, size: e.size, tag: el ? el.tagName.toLowerCase() : null, src: e.url || null,
loading: el && el.getAttribute ? el.getAttribute('loading') : null,
fetchpriority: el && el.getAttribute ? el.getAttribute('fetchpriority') : null }
} }).observe({ buffered: true, type: 'largest-contentful-paint' })
new PerformanceObserver((l) => { for (const e of l.getEntries()) {
if (e.hadRecentInput) continue
if (win && e.startTime - winLast < 1000 && e.startTime - winStart < 5000) { win += e.value } else { win = e.value; winStart = e.startTime }
winLast = e.startTime
v.cls = Math.max(v.cls, win)
} }).observe({ buffered: true, type: 'layout-shift' })
new PerformanceObserver((l) => { for (const e of l.getEntries()) v.longTasks.push([e.startTime, e.duration]) }).observe({ buffered: true, type: 'longtask' })
new PerformanceObserver((l) => { for (const e of l.getEntries()) v.events.push({ d: e.duration, n: e.name }) }).observe({ buffered: true, durationThreshold: 16, type: 'event' })
})()`
/**
* @typedef {{ bytes: { css: number, font: number, html: number, image: number, js: number, other: number }, cls: number,
* fcp: null | number, inp: null | number, interaction: null | string, lcp: null | number,
* lcpElement: null | { fetchpriority: null | string, loading: null | string, src: null | string, tag: null | string },
* load: null | number, profile: string, renderBlocking: string[], requests: number, runs?: number, scriptMs: null | number,
* status: null | number, tbt: null | number, thirdParty: string[], ttfb: null | number, url: string }} PageMeasurement
*/
const typeOf = (resourceType, mime = '') => {
if (resourceType === 'Document') {return 'html'}
if (resourceType === 'Script') {return 'js'}
if (resourceType === 'Stylesheet') {return 'css'}
if (resourceType === 'Font') {return 'font'}
if (resourceType === 'Image' || mime.startsWith('image/')) {return 'image'}
return 'other'
}
/**
* @param {import('@playwright/test').Browser} browser
* @param {string} url
* @param {'mobile'|'desktop'} profileName
* @param {{ interact?: boolean, settleMs?: number }} [options]
* @returns {Promise<PageMeasurement>}
*/
export async function measurePage(browser, url, profileName, options = {}) {
const profile = PROFILES[profileName]
const context = await browser.newContext({ ...profile.viewport, viewport: { height: profile.viewport.height, width: profile.viewport.width } })
const page = await context.newPage()
const cdp = await context.newCDPSession(page)
await cdp.send('Network.enable')
await cdp.send('Network.setCacheDisabled', { cacheDisabled: true })
await cdp.send('Network.emulateNetworkConditions', { offline: false, ...profile.network })
await cdp.send('Emulation.setCPUThrottlingRate', { rate: profile.cpu })
await cdp.send('Performance.enable')
await page.addInitScript(OBSERVERS)
const origin = new URL(url).origin
const requests = new Map()
cdp.on('Network.requestWillBeSent', (e) => { if (!e.request.url.startsWith('data:')) {requests.set(e.requestId, { bytes: 0, type: typeOf(e.type), url: e.request.url })} })
cdp.on('Network.responseReceived', (e) => { const r = requests.get(e.requestId); if (r) {r.type = typeOf(e.type, e.response.mimeType); r.status = e.response.status} })
cdp.on('Network.loadingFinished', (e) => { const r = requests.get(e.requestId); if (r) {r.bytes = e.encodedDataLength} })
const response = await page.goto(url, { waitUntil: 'load' })
await page.waitForLoadState('networkidle').catch(() => {})
await page.waitForTimeout(options.settleMs ?? 1000)
let interaction = null
if (options.interact !== false) {
// INP stand-in: one click on the first visible button (menu toggle, cookie settings, theme): a real handler runs
const button = page.locator('button:visible').first()
if (await button.count()) {
interaction = (await button.getAttribute('aria-label')) ?? (await button.innerText()).slice(0, 40)
await button.click({ timeout: 5000 }).catch(() => { interaction = null })
await page.waitForTimeout(500)
}
}
const nav = await page.evaluate(() => {
const n = performance.getEntriesByType('navigation')[0]
const fcp = performance.getEntriesByName('first-contentful-paint')[0]
const blocking = performance.getEntriesByType('resource').filter((r) => r.renderBlockingStatus === 'blocking').map((r) => r.name)
return { blocking, domContentLoaded: n.domContentLoadedEventEnd, fcp: fcp ? fcp.startTime : null, load: n.loadEventEnd, ttfb: n.responseStart }
})
const vitals = await page.evaluate(() => window.__perf)
const { metrics } = await cdp.send('Performance.getMetrics')
const metric = (name) => metrics.find((m) => m.name === name)?.value ?? 0
await context.close()
const list = [...requests.values()]
const bytes = { css: 0, font: 0, html: 0, image: 0, js: 0, other: 0 }
for (const r of list) {bytes[r.type] += r.bytes}
const fcp = nav.fcp ?? 0
const tbt = vitals.longTasks.filter(([start]) => start >= fcp).reduce((sum, [, d]) => sum + Math.max(0, d - 50), 0)
const round = (n) => (n == null ? null : Math.round(n))
return {
bytes: Object.fromEntries(Object.entries(bytes).map(([k, b]) => [k, Math.round(b)])),
cls: Math.round(vitals.cls * 1000) / 1000,
fcp: round(nav.fcp),
inp: vitals.events.length ? round(Math.max(...vitals.events.map((e) => e.d))) : interaction ? 0 : null,
interaction,
lcp: round(vitals.lcp?.at),
lcpElement: vitals.lcp ? { fetchpriority: vitals.lcp.fetchpriority, loading: vitals.lcp.loading, src: vitals.lcp.src ? vitals.lcp.src.replace(origin, '') : null, tag: vitals.lcp.tag } : null,
load: round(nav.load),
profile: profileName,
renderBlocking: nav.blocking.map((u) => u.replace(origin, '')),
requests: list.length,
scriptMs: round(metric('ScriptDuration') * 1000),
status: response?.status() ?? null,
tbt: round(tbt),
thirdParty: [...new Set(list.filter((r) => !r.url.startsWith(origin)).map((r) => new URL(r.url).origin))],
ttfb: round(nav.ttfb),
url: url.replace(origin, ''),
}
}
export const median = (values) => {
const sorted = values.filter((v) => typeof v === 'number').sort((a, b) => a - b)
if (!sorted.length) {return null}
const mid = Math.floor(sorted.length / 2)
return sorted.length % 2 ? sorted[mid] : Math.round(((sorted[mid - 1] + sorted[mid]) / 2) * 1000) / 1000
}
/**
* The median of `runs` measurements for every number; the rest from the last run.
* @param {import('@playwright/test').Browser} browser
* @param {string} url
* @param {'mobile'|'desktop'} profileName
* @param {number} [runs]
* @param {{ interact?: boolean, settleMs?: number }} [options]
* @returns {Promise<PageMeasurement>}
*/
export async function measureMedian(browser, url, profileName, runs = 3, options = {}) {
const all = []
for (let i = 0; i < runs; i++) {all.push(await measurePage(browser, url, profileName, options))}
const last = all.at(-1)
const out = { ...last, runs }
for (const key of ['cls', 'fcp', 'inp', 'lcp', 'load', 'requests', 'scriptMs', 'tbt', 'ttfb']) {out[key] = median(all.map((r) => r[key]))}
out.bytes = Object.fromEntries(Object.keys(last.bytes).map((k) => [k, median(all.map((r) => r.bytes[k]))]))
return out
}
export const launch = () => chromium.launch()
+162
View File
@@ -0,0 +1,162 @@
#!/usr/bin/env node
/**
* pnpm perf:measure — measures the BUILT reference site (reference/) and writes the numbers to a JSON file.
* The method behind docs/performance.md → "How the plugin is measured"; repeat it after a change and compare.
*
* Before: reference/.env filled (local seeded MongoDB, ALLOW_LOCAL_MEDIA=1), the plugin built, `pnpm build` in
* reference/ (webpack; `pnpm exec next build --turbopack` for Turbopack). The script starts `next start` itself.
*
* node scripts/perf-measure.mjs --label=webpack-before [--runs=3] [--port=3370] [--out=file.json] [--no-server]
*
* Server side: cold start (spawn → /api/health answers, → first page), memory (RSS of the server after the run),
* TTFB of a cached (ISR) page over 20 requests, and the cost of RENDERING each page once: the request carries
* Next's `x-prerender-revalidate` header (the on-demand revalidation Next uses itself), so the page is rendered
* now and not served from the ISR cache; MongoDB's profiler (level 2, the database in DATABASE_URI) counts every
* query that render made and their time. The profiler is switched off again at the end.
* Client side: e2e/perf-lab.mjs (Lighthouse's mobile and desktop profiles), the median of --runs runs per page.
*/
import { execFileSync, spawn } from 'node:child_process'
import { readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { launch, measureMedian } from '../reference/e2e/perf-lab.mjs'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const site = path.join(root, 'reference')
const arg = (name, fallback) => process.argv.find((a) => a.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback
const label = arg('label', 'run')
const runs = Number(arg('runs', 3))
const env = Object.fromEntries(readFileSync(path.join(site, '.env'), 'utf8').split('\n').filter((l) => /^[A-Z0-9_]+=/.test(l)).map((l) => [l.slice(0, l.indexOf('=')), l.slice(l.indexOf('=') + 1)]))
const port = Number(arg('port', new URL(env.NEXT_PUBLIC_SERVER_URL ?? 'http://localhost:3370').port || 3370))
const base = `http://localhost:${port}`
const out = arg('out', path.join(root, 'docs', 'dev', 'perf', `${label}.json`))
/** The page types measured: one of each template the reference site has (AGENTS.md → Site map). */
export const PAGES = {
home: '/pl',
page: '/pl/o-nas',
archive: '/pl/blog',
post: '/pl/blog/zanim-kupisz-dzialke',
caseStudy: '/pl/realizacje/dom-pod-lasem',
form: '/pl/wycena',
showcase: '/pl/bloki',
notFound: '/pl/nie-ma-takiej-strony',
}
// --- MongoDB profiler (through the mongo container's shell when DATABASE_URI is local; else skipped) ---
const dbUri = process.env.DATABASE_URI ?? env.DATABASE_URI
const dbName = new URL(dbUri).pathname.slice(1)
const container = arg('mongo-container', process.env.PERF_MONGO_CONTAINER ?? '')
const mongo = (js) => {
if (!container) {return null}
return execFileSync('docker', ['exec', container, 'mongosh', '--quiet', dbName, '--eval', js], { encoding: 'utf8' }).trim()
}
const profileOn = () => mongo('db.setProfilingLevel(0); db.system.profile.drop(); db.setProfilingLevel(2); "ok"')
const profileOff = () => mongo('db.setProfilingLevel(0); "ok"')
const profileRead = () => {
const raw = mongo(`JSON.stringify(db.system.profile.find({ ns: { $not: /system\\.profile$/ }, op: { $in: ['query','command','getmore','insert','update','remove'] } }, { millis: 1, ns: 1, op: 1, 'command.find': 1, 'command.aggregate': 1, 'command.count': 1 }).toArray())`)
if (raw == null) {return null}
const rows = JSON.parse(raw).filter((r) => !r.command || r.command.find || r.command.aggregate || r.command.count || r.op !== 'command')
mongo('db.setProfilingLevel(0); db.system.profile.drop(); db.setProfilingLevel(2); "ok"')
const byCollection = {}
for (const r of rows) {const c = r.ns.split('.').slice(1).join('.'); byCollection[c] = (byCollection[c] ?? 0) + 1}
return { byCollection, count: rows.length, ms: rows.reduce((s, r) => s + (r.millis ?? 0), 0) }
}
const waitFor = async (url, timeoutMs = 60000) => {
const start = Date.now()
while (Date.now() - start < timeoutMs) {
try {
if ((await fetch(url)).ok) {return Date.now() - start}
} catch {}
await new Promise((r) => setTimeout(r, 100))
}
throw new Error(`${url} did not answer in ${timeoutMs} ms`)
}
const timed = async (url, init) => {
const t = performance.now()
const res = await fetch(url, { redirect: 'manual', ...init })
await res.arrayBuffer()
return { ms: performance.now() - t, res }
}
const pct = (values, p) => {
const s = [...values].sort((a, b) => a - b)
return Math.round(s[Math.min(s.length - 1, Math.floor((p / 100) * s.length))] * 10) / 10
}
const rssOf = (pid) => {
// the server is `node … next start` under pnpm: sum the process tree's RSS (KiB → MiB)
const tree = execFileSync('ps', ['-A', '-o', 'pid=,ppid=,rss='], { encoding: 'utf8' }).trim().split('\n').map((l) => l.trim().split(/\s+/).map(Number))
const ids = new Set([pid])
for (let changed = true; changed;) {
changed = false
for (const [p, pp] of tree) {if (ids.has(pp) && !ids.has(p)) {ids.add(p); changed = true}}
}
return Math.round(tree.filter(([p]) => ids.has(p)).reduce((s, [, , rss]) => s + rss, 0) / 1024)
}
const result = { client: {}, date: new Date().toISOString(), label, method: 'scripts/perf-measure.mjs + reference/e2e/perf-lab.mjs', runs, server: {} }
let server = null
if (!process.argv.includes('--no-server')) {
// another server on the port would be measured instead of this build (and a stale .next answers 404 for assets)
if (await fetch(`${base}/api/health`).then(() => true, () => false)) {
console.error(`[perf] ${base} already answers: stop that server first (lsof -ti tcp:${port} | xargs kill) or pass --no-server`)
process.exit(2)
}
const t0 = Date.now()
server = spawn('pnpm', ['start'], { cwd: site, env: { ...process.env, PORT: String(port) }, detached: true, stdio: ['ignore', 'ignore', 'inherit'] })
result.server.coldStartHealthMs = await waitFor(`${base}/api/health`)
const first = await timed(`${base}${PAGES.home}`)
result.server.coldStartFirstPageMs = Date.now() - t0
result.server.firstPageMs = Math.round(first.ms)
}
try {
// TTFB of a cached page and of the dynamic routes the plugin serves
for (const [name, p] of Object.entries({ home: PAGES.home, md: '/md/pl', sitemap: '/sitemap.xml', llms: '/llms.txt' })) {
await timed(`${base}${p}`)
const times = []
for (let i = 0; i < 20; i++) {times.push((await timed(`${base}${p}`)).ms)}
result.server[`ttfb_${name}`] = { median: pct(times, 50), p95: pct(times, 95) }
}
// the cost of one render of each page (ISR bypassed), with the queries it made
const manifest = JSON.parse(readFileSync(path.join(site, '.next', 'prerender-manifest.json'), 'utf8'))
const previewModeId = manifest.preview?.previewModeId
result.server.render = {}
if (profileOn() == null) {result.server.queriesNote = 'no --mongo-container: query counts not measured'}
for (const [name, p] of Object.entries(PAGES)) {
profileRead()
const renders = []
for (let i = 0; i < 3; i++) {renders.push((await timed(`${base}${p}`, { headers: previewModeId ? { 'x-prerender-revalidate': previewModeId } : {} })).ms)}
const q = profileRead()
result.server.render[name] = { medianMs: pct(renders, 50), queries: q ? Math.round(q.count / 3) : null, queryMs: q ? Math.round(q.ms / 3) : null, byCollection: q?.byCollection }
}
for (const [name, p] of Object.entries({ md: '/md/pl', sitemap: '/sitemap.xml', llms: '/llms.txt', llmsFull: '/llms-full.txt' })) {
profileRead()
const { ms } = await timed(`${base}${p}`)
const q = profileRead()
result.server.render[name] = { medianMs: Math.round(ms), queries: q?.count ?? null, queryMs: q?.ms ?? null, byCollection: q?.byCollection }
}
profileOff()
const browser = await launch()
for (const profile of ['mobile', 'desktop']) {
result.client[profile] = {}
for (const [name, p] of Object.entries(PAGES)) {
result.client[profile][name] = await measureMedian(browser, `${base}${p}`, profile, runs)
const r = result.client[profile][name]
console.log(`[perf] ${profile.padEnd(7)} ${name.padEnd(9)} LCP ${r.lcp} CLS ${r.cls} TBT ${r.tbt} INP ${r.inp} JS ${r.bytes.js} CSS ${r.bytes.css} req ${r.requests}`)
}
}
result.client.admin = await measureMedian(browser, `${base}/admin/login`, 'desktop', runs, { interact: false })
await browser.close()
if (server) {result.server.rssMiB = rssOf(server.pid)}
} finally {
profileOff()
if (server) {
try { process.kill(-server.pid, 'SIGTERM') } catch {} // the whole process group: pnpm and next start
}
}
writeFileSync(out, `${JSON.stringify(result, null, 2)}\n`)
console.log(`[perf] written ${path.relative(root, out)}`)
console.log(JSON.stringify(result.server, null, 1))
process.exit(0)