From 258b20417a16ab30ccce7b71866af1afa1823e2d Mon Sep 17 00:00:00 2001 From: 1aron Date: Mon, 29 Jan 2024 12:41:21 +0800 Subject: [PATCH] Fix fetchWithBrotli function and add date to results.json --- .../critical-css-for-docs-sites/index.js | 15 ++++++----- .../critical-css-for-docs-sites/results.json | 27 ++++++++++++------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/benchmarks/critical-css-for-docs-sites/index.js b/benchmarks/critical-css-for-docs-sites/index.js index 249ac33d7..feb948621 100644 --- a/benchmarks/critical-css-for-docs-sites/index.js +++ b/benchmarks/critical-css-for-docs-sites/index.js @@ -19,7 +19,7 @@ async function fetchWithBrotli(url) { 'Accept-Encoding': 'br' } }) - return response; + return response } catch (error) { if (error.response.status === 404) { return error.response @@ -28,12 +28,12 @@ async function fetchWithBrotli(url) { } async function fetchAndCalculateCSS({ name, url }) { - const response = await fetchWithBrotli(url); - const $ = cheerio.load(response.data.toString()); - const domain = response.request.protocol + '//' + response.request.host; + const response = await fetchWithBrotli(url) + const $ = cheerio.load(response.data.toString()) + const domain = response.request.protocol + '//' + response.request.host let totalInternalCSSSize = 0 let totalInternalCSSBrotliSize = 0 - let totalExternalCSSSize = 0; + let totalExternalCSSSize = 0 let totalExternalCSSBrotliSize = 0 let externals = [] let internals = [] @@ -71,7 +71,7 @@ async function fetchAndCalculateCSS({ name, url }) { size: styleSize, brotliSize: styleBrotliSize }) - }); + }) return { name, @@ -83,7 +83,8 @@ async function fetchAndCalculateCSS({ name, url }) { totalExternalCSSSize, totalExternalCSSBrotliSize, externals, - internals + internals, + date: new Date().toISOString() } } diff --git a/benchmarks/critical-css-for-docs-sites/results.json b/benchmarks/critical-css-for-docs-sites/results.json index 7ce9f357a..ca741c6ba 100644 --- a/benchmarks/critical-css-for-docs-sites/results.json +++ b/benchmarks/critical-css-for-docs-sites/results.json @@ -46,7 +46,8 @@ "size": 96, "brotliSize": 52 } - ] + ], + "date": "2024-01-29T03:51:16.140Z" }, { "name": "React", @@ -64,7 +65,8 @@ "brotliSize": 15976 } ], - "internals": [] + "internals": [], + "date": "2024-01-29T03:51:15.998Z" }, { "name": "Vue.js", @@ -82,7 +84,8 @@ "brotliSize": 21082 } ], - "internals": [] + "internals": [], + "date": "2024-01-29T03:51:16.365Z" }, { "name": "Angular", @@ -181,7 +184,8 @@ "size": 1883, "brotliSize": 507 } - ] + ], + "date": "2024-01-29T03:51:16.716Z" }, { "name": "Bootstrap", @@ -209,7 +213,8 @@ "brotliSize": 7332 } ], - "internals": [] + "internals": [], + "date": "2024-01-29T03:51:18.010Z" }, { "name": "Tailwind CSS", @@ -227,15 +232,16 @@ "brotliSize": 37021 } ], - "internals": [] + "internals": [], + "date": "2024-01-29T03:51:17.367Z" }, { "name": "Master CSS", "url": "https://rc.css.master.co/docs", "totalCSSSize": 30674, - "totalCSSBrotliSize": 6553, + "totalCSSBrotliSize": 6557, "totalInternalCSSSize": 28435, - "totalInternalCSSBrotliSize": 5706, + "totalInternalCSSBrotliSize": 5710, "totalExternalCSSSize": 2239, "totalExternalCSSBrotliSize": 847, "externals": [ @@ -249,7 +255,7 @@ { "tag": "