Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add total blocking time to report #4

Merged
merged 2 commits into from Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified docs/assets/console_usage.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions lib/pagespeed.js
Expand Up @@ -69,6 +69,12 @@ const metricsToParse = [
metricPath: "lhr.audits.server-response-time.numericValue",
metricUnit: "ms",
},
{
label: "Total Blocking Time",
scorePath: "lhr.audits.total-blocking-time.score",
metricPath: "lhr.audits.total-blocking-time.numericValue",
metricUnit: "ms",
},
];

const parseMetrics = function (results, runs = 1) {
Expand Down
16 changes: 13 additions & 3 deletions lib/renderReport.js
Expand Up @@ -5,13 +5,17 @@ const fs = require("fs");
const parser = require("url");

const generateMarkdown = (metrics, runs) => {
let md = `| Run # | PS | FCP (ms) | LCP (ms) | SI (ms) | CLS | SRT (ms) |
|- |- |- |- |- |- |- |\n`;
let md = `| Run # | PS | FCP (ms) | LCP (ms) | SI (ms) | CLS | SRT (ms) | TBT (ms) |
|- |- |- |- |- |- |- |- |\n`;

for (let run = 1; run <= runs; run++) {
const cols = [
run,
_.get(metrics, `performanceScore.actual.scores.${run - 1}`, 0),
_.get(
metrics,
`performanceScore.actual.scores.${run - 1}`,
0
).toFixed(0),
_.get(
metrics,
`firstContentfulPaint.actual.numericValues.${run - 1}`,
Expand All @@ -35,6 +39,11 @@ const generateMarkdown = (metrics, runs) => {
`serverResponseTime.actual.numericValues.${run - 1}`,
0
).toFixed(2),
_.get(
metrics,
`totalBlockingTime.actual.numericValues.${run - 1}`,
0
).toFixed(2),
];
md = md.concat(`| ${cols.join(" | ")} |\n`);

Expand All @@ -47,6 +56,7 @@ const generateMarkdown = (metrics, runs) => {
_.get(metrics, `speedIndex.average.numericValue`),
_.get(metrics, `cumulativeLayoutShift.average.numericValue`),
_.get(metrics, `serverResponseTime.average.numericValue`),
_.get(metrics, `totalBlockingTime.average.numericValue`),
];

md = md.concat(`| ${avgCols.join(" | ")} |\n`);
Expand Down
2 changes: 1 addition & 1 deletion terminal-demo.yml
Expand Up @@ -197,6 +197,6 @@ records:
- delay: 750
content: "Run 5 for https://bankrate.com\r\n"
- delay: 750
content: "\e[4m\e[24m\r\n\e[4mAverage performance\e[24m\r\nPerformance Score: \e[33m36\e[39m\r\nFirst Contentful Paint: \e[32m3062.76ms\e[39m\r\nLargest Contentful Paint: \e[31m7535.74ms\e[39m\r\nSpeed Index: \e[33m6005.77ms\e[39m\r\nCumulative Layout Shift: \e[31m1.46\e[39m\r\nServer Response Time: \e[32m50.20ms\e[39m\r\n"
content: "\e[4m\e[24m\r\n\e[4mAverage performance\e[24m\r\nPerformance Score: \e[33m36\e[39m\r\nFirst Contentful Paint: \e[32m3062.76ms\e[39m\r\nLargest Contentful Paint: \e[31m7535.74ms\e[39m\r\nSpeed Index: \e[33m6005.77ms\e[39m\r\nCumulative Layout Shift: \e[31m1.46\e[39m\r\nServer Response Time: \e[32m50.20ms\e[39m\r\nTotal Blocking Time: \e[33m446.50ms\e[39m\r\n"
- delay: 3000
content: "\r\n> "