Skip to content

Commit

Permalink
Merge pull request #4 from brentmullen/feat/add-tbt
Browse files Browse the repository at this point in the history
feat: add total blocking time to report
  • Loading branch information
chaseconey committed Nov 3, 2020
2 parents 0ce62e7 + c981f84 commit 444d6f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
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> "

0 comments on commit 444d6f0

Please sign in to comment.