From f3f6b61a4ffc444120be7bb048da514fe50ea678 Mon Sep 17 00:00:00 2001 From: Stoyan Date: Wed, 13 Dec 2023 20:11:21 -0800 Subject: [PATCH 1/7] fix low-contrast text --- www/assets/css/pagestyle2.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/assets/css/pagestyle2.css b/www/assets/css/pagestyle2.css index 9d3675b213..17d6de4138 100644 --- a/www/assets/css/pagestyle2.css +++ b/www/assets/css/pagestyle2.css @@ -7248,7 +7248,7 @@ td { font-weight: 500; display: block; font-size: 0.9em; - color: #d580ff; + color: #b2bacb; padding-top: 0.4em; } From 6a45898bcdc971f0946f65bad7ad5c10db32b4cb Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:18:33 +0530 Subject: [PATCH 2/7] Update common.inc --- www/experiments/common.inc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/www/experiments/common.inc b/www/experiments/common.inc index aba4f5611e..f698a65d1b 100644 --- a/www/experiments/common.inc +++ b/www/experiments/common.inc @@ -1,5 +1,6 @@ $cat) { $assessment[$key]["num_good"] = $numGood; $assessment[$key]["num_bad"] = $numChecks - $numGood; - - if ($key === "Quick") { // build sentiment $summary = "This site "; $ttfbCheck = $testStepResult->getMetric('TTFB'); - if ($ttfbCheck > 2000) { + if ($ttfbCheck > $MetricThresholds['TTBF_POOR']) { $summary .= "was very slow"; - } elseif ($ttfbCheck > 1000) { + } elseif ($ttfbCheck > $MetricThresholds['TTBF_OK']) { $summary .= "took little time"; } else { $summary .= "was quick"; @@ -176,10 +175,9 @@ foreach ($assessment as $key => $cat) { $summary .= " to connect and deliver initial code. It began rendering content"; $fcpCheck = $testStepResult->getMetric('firstContentfulPaint'); - $fcpCheck = $fcpCheck / 1000; - if ($fcpCheck > 5) { + if ($fcpCheck > $MetricThresholds['FCP_POOR']) { $summary .= " with considerable delay."; - } elseif ($fcpCheck > 2) { + } elseif ($fcpCheck > $MetricThresholds['FCP_OK']) { $summary .= " with little delay."; } else { $summary .= " very quickly."; @@ -193,9 +191,9 @@ foreach ($assessment as $key => $cat) { if (isset($lcp)) { $summary .= " The largest content rendered "; - if ($lcp['time'] > 3500) { + if ($lcp['time'] > $MetricThresholds['LCP_POOR']) { $summary .= " later than ideal."; - } elseif ($lcp['time'] > 2500) { + } elseif ($lcp['time'] > $MetricThresholds['LCP_OK']) { $summary .= " a little late."; } else { $summary .= " quickly."; @@ -205,9 +203,9 @@ foreach ($assessment as $key => $cat) { // build sentiment $summary = "This site "; if (isset($cls)) { - if ($cls > .25) { + if ($cls > $MetricThresholds['CLS_POOR']) { $summary .= "had major layout shifts"; - } elseif ($cls > 0) { + } elseif ($cls > $MetricThresholds['CLS_OK']) { $summary .= "had minor layout shifts"; } else { $summary .= "had good layout stability"; @@ -218,9 +216,9 @@ foreach ($assessment as $key => $cat) { $tbtCheck = $testStepResult->getMetric('TotalBlockingTime'); if (isset($tbtCheck)) { (isset($cls)) ? $summary .= " It took" : $summary .= "took"; - if ($tbtCheck > 1000) { + if ($tbtCheck > $MetricThresholds['TBT_POOR']) { $summary .= " a long time"; - } elseif ($tbtCheck > 500) { + } elseif ($tbtCheck > $MetricThresholds['TBT_OK']) { $summary .= " some time"; } else { $summary .= " little time"; @@ -243,7 +241,7 @@ foreach ($assessment as $key => $cat) { $genContentSize = floatval($genContentSize); $genContentPercent = floatval($genContentPercent); - if ($genContentSize > .5 || $genContentPercent > 1) { + if ($genContentSize > $MetricThresholds['RenderBlockingContentSizeCheck'] || $genContentPercent > $MetricThresholds['RenderBlockingContentPercentCheck']) { $summary .= " Some HTML was generated after delivery, potentially delaying usability."; } else { $summary .= " HTML content was mostly generated server-side."; @@ -253,7 +251,7 @@ foreach ($assessment as $key => $cat) { // build sentiment $summary = "This site "; if (isset($blocking3pReqs)) { - if (count($blocking3pReqs) > 2) { + if (count($blocking3pReqs) > $MetricThresholds['RenderBlockingThirdPartyRequestsCheck']) { $summary .= "had many"; } elseif (count($blocking3pReqs) > 0) { $summary .= "had"; @@ -280,7 +278,7 @@ foreach ($assessment as $key => $cat) { $genContentSize = floatval($genContentSize); $genContentPercent = floatval($genContentPercent); - if ($genContentSize > .5 || $genContentPercent > 1) { + if ($genContentSize > $MetricThresholds['RenderBlockingContentSizeCheck'] || $genContentPercent > $MetricThresholds['RenderBlockingContentPercentCheck']) { $summary .= " Some HTML was generated after delivery, which can cause fragility."; } else { $summary .= " HTML content was mostly generated server-side."; From 1e25840f69bd3b0ae0352085f7d2f356625a6787 Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:20:20 +0530 Subject: [PATCH 3/7] Update RunResultHtmlTable.php --- www/include/RunResultHtmlTable.php | 113 +++++++++++++++-------------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/www/include/RunResultHtmlTable.php b/www/include/RunResultHtmlTable.php index ae5187bd6a..a1e6d1448c 100644 --- a/www/include/RunResultHtmlTable.php +++ b/www/include/RunResultHtmlTable.php @@ -8,6 +8,7 @@ use WebPageTest\TestResults\Timings; require_once INCLUDES_PATH . '/common_lib.inc'; +require_once INCLUDES_PATH . '/include/thresholds.inc'; class RunResultHtmlTable { @@ -35,9 +36,9 @@ class RunResultHtmlTable const COL_ENV_IMP = 'carbon-footprint'; - /* @var TestInfo */ + /* @var TestInfo */ private $testInfo; - /* @var TestRunResults */ + /* @var TestRunResults */ private $runResults; private $rvRunResults; @@ -50,12 +51,12 @@ class RunResultHtmlTable private $showCustomMetrics = true; - /** - * RunResultHtmlTable constructor. - * @param TestInfo $testInfo - * @param TestRunResults $runResults - * @param TestRunResults $rvRunResults Optional. Run results of the repeat view - */ + /** + * RunResultHtmlTable constructor. + * @param TestInfo $testInfo + * @param TestRunResults $runResults + * @param TestRunResults $rvRunResults Optional. Run results of the repeat view + */ public function __construct($testInfo, $runResults, $rvRunResults = null, $useShortNames = true, $useDescs = false) { $this->testInfo = $testInfo; @@ -67,45 +68,46 @@ public function __construct($testInfo, $runResults, $rvRunResults = null, $useSh $this->useShortNames = $useShortNames; $this->useDescs = $useDescs; $this->enabledColumns = array(); - // optional columns default setting based on data + // optional columns default setting based on data $this->enabledColumns[self::COL_LABEL] = $this->testInfo->getRuns() > 1 || $this->isMultistep || $this->rvRunResults; $this->enabledColumns[self::COL_RESULT] = true; $this->enabledColumns[self::COL_CERTIFICATE_BYTES] = $runResults->hasValidNonZeroMetric('certificate_bytes'); - $checkByMetric = array(self::COL_FIRST_CONTENTFUL_PAINT, self::COL_SPEED_INDEX, self::COL_TIME_TO_INTERACTIVE, - self::COL_LARGEST_CONTENTFUL_PAINT, self::COL_CUMULATIVE_LAYOUT_SHIFT, self::COL_TOTAL_BLOCKING_TIME, self::COL_ENV_IMP); + $checkByMetric = array( + self::COL_FIRST_CONTENTFUL_PAINT, self::COL_SPEED_INDEX, self::COL_TIME_TO_INTERACTIVE, + self::COL_LARGEST_CONTENTFUL_PAINT, self::COL_CUMULATIVE_LAYOUT_SHIFT, self::COL_TOTAL_BLOCKING_TIME, self::COL_ENV_IMP + ); foreach ($checkByMetric as $col) { $this->enabledColumns[$col] = $runResults->hasValidMetric($col) || - ($rvRunResults && $rvRunResults->hasValidMetric($col)); + ($rvRunResults && $rvRunResults->hasValidMetric($col)); } - // disable env impact if not collected - if (count($this->runResults->getStepResult(1)->getMetric(self::COL_ENV_IMP)) === 0) { + $m = $this->runResults->getStepResult(1)->getMetric(self::COL_ENV_IMP); + if ($m != null && count($m) === 0) { $this->enabledColumns[self::COL_ENV_IMP] = false; } - - // If strict_video = 1, only show if metric is present, otherwise alway show + // If strict_video = 1, only show if metric is present, otherwise alway show if (GetSetting('strict_video')) { array_push($this->leftOptionalColumns, self::COL_START_RENDER); $this->enabledColumns[self::COL_START_RENDER] = $runResults->hasValidMetric(self::COL_START_RENDER) || - ($rvRunResults && $rvRunResults->hasValidMetric(self::COL_START_RENDER)); + ($rvRunResults && $rvRunResults->hasValidMetric(self::COL_START_RENDER)); } else { $this->enabledColumns[self::COL_START_RENDER] = true; } } - /** - * @param bool $use True to use links for the labels, false otherwise - */ + /** + * @param bool $use True to use links for the labels, false otherwise + */ public function useLabelLinks($use) { $this->enableLabelLinks = $use; } - /** - * @param string[] $columns The columns to enable (one of the COL_ constants) - */ + /** + * @param string[] $columns The columns to enable (one of the COL_ constants) + */ public function enableColumns($columns) { foreach ($columns as $column) { @@ -113,9 +115,9 @@ public function enableColumns($columns) } } - /** - * @param string[] $columns The columns to disable (one of the COL_ constants) - */ + /** + * @param string[] $columns The columns to disable (one of the COL_ constants) + */ public function disableColumns($columns) { foreach ($columns as $column) { @@ -123,10 +125,10 @@ public function disableColumns($columns) } } - /** - * @param string $column The column to show or not show (one of the COL_ comnstants) - * @return bool True if the column is enabled, false otherwise - */ + /** + * @param string $column The column to show or not show (one of the COL_ comnstants) + * @return bool True if the column is enabled, false otherwise + */ public function isColumnEnabled($column) { return !empty($this->enabledColumns[$column]); @@ -163,7 +165,7 @@ private function _createHead($cachedRun = false) // TODO test multistep //$out .= $this->_headCell("Step"); } else { - //$out .= $this->_headCell("", "empty pin", 1); + //$out .= $this->_headCell("", "empty pin", 1); } } if ($this->useShortNames) { @@ -188,7 +190,7 @@ private function _createHead($cachedRun = false) $out .= $this->_headCell("Result (error code)"); } $vitalsBorder = "border"; - //for now, only provide a link to vitals if all metrics are collected + //for now, only provide a link to vitals if all metrics are collected if ( $this->isColumnEnabled(self::COL_LARGEST_CONTENTFUL_PAINT) && $this->isColumnEnabled(self::COL_CUMULATIVE_LAYOUT_SHIFT) && @@ -281,7 +283,7 @@ private function _createFoot($cachedRun = false) // TODO test multistep //$out .= $this->_headCell("Step"); } else { - //$out .= $this->_headCell("", "empty pin", 1); + //$out .= $this->_headCell("", "empty pin", 1); } } $out .= $this->_bodyCell(null, "When did the content start downloading?"); @@ -302,7 +304,7 @@ private function _createFoot($cachedRun = false) $out .= $this->_bodyCell(null, "What error code was shown?"); } $vitalsBorder = "border"; - //for now, only provide a link to vitals if all metrics are collected + //for now, only provide a link to vitals if all metrics are collected if ( $this->isColumnEnabled(self::COL_LARGEST_CONTENTFUL_PAINT) && $this->isColumnEnabled(self::COL_CUMULATIVE_LAYOUT_SHIFT) && @@ -364,7 +366,7 @@ private function _createFoot($cachedRun = false) } if ($this->isColumnEnabled(self::COL_COST)) { - // $out .= $this->_headCell("Cost"); + // $out .= $this->_headCell("Cost"); $out .= $this->_bodyCell("", "What was the avg. download cost?"); } if ($this->isColumnEnabled(self::COL_ENV_IMP)) { @@ -408,13 +410,14 @@ private function _rvLabel($isRepeatView, $runNumber) return $label; } - /** - * @param TestStepResult $stepResult - * @param int $row Row number - * @return string HTML Table row - */ + /** + * @param TestStepResult $stepResult + * @param int $row Row number + * @return string HTML Table row + */ private function _createRow($stepResult, $row, $repeatMetricLabels = false) { + global $MetricThresholds; $stepNum = $stepResult->getStepNumber(); $cachedRun = $stepResult->isCachedRun(); $idPrefix = ""; @@ -468,9 +471,9 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) $value = $this->_getIntervalMetric($stepResult, self::COL_LARGEST_CONTENTFUL_PAINT); $rawValue = $stepResult->getMetric(self::COL_LARGEST_CONTENTFUL_PAINT); $scoreClass = 'good'; - if ($rawValue >= 4000) { + if ($rawValue >= $MetricThresholds['LCP_POOR']) { $scoreClass = 'poor'; - } elseif ($rawValue >= 2500) { + } elseif ($rawValue >= $MetricThresholds['LCP_OK']) { $scoreClass = 'ok'; } $vclass = $vitalsClass ? ($vitalsClass . ' ' . $scoreClass) : $scoreClass; @@ -482,9 +485,9 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) $value = round($this->_getSimpleMetric($stepResult, self::COL_CUMULATIVE_LAYOUT_SHIFT), 3); $rawValue = $stepResult->getMetric(self::COL_CUMULATIVE_LAYOUT_SHIFT); $scoreClass = 'good'; - if ($rawValue >= 0.25) { + if ($rawValue >= $MetricThresholds['CLS_POOR']) { $scoreClass = 'poor'; - } elseif ($rawValue >= 0.1) { + } elseif ($rawValue >= $MetricThresholds['CLS_OK']) { $scoreClass = 'ok'; } $vclass = $vitalsClass ? ($vitalsClass . ' ' . $scoreClass) : $scoreClass; @@ -500,9 +503,9 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) } $rawValue = $stepResult->getMetric(self::COL_TOTAL_BLOCKING_TIME); $scoreClass = 'good'; - if ($rawValue >= 600) { + if ($rawValue >= $MetricThresholds['TBT_POOR']) { $scoreClass = 'poor'; - } elseif ($rawValue >= 300) { + } elseif ($rawValue >= $MetricThresholds['TBT_OK']) { $scoreClass = 'ok'; } $vclass = $vitalsClass ? ($vitalsClass . ' ' . $scoreClass) : $scoreClass; @@ -539,7 +542,7 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) } } if ($this->isColumnEnabled(self::COL_ENV_IMP)) { - $out .= $this->_bodyCell($idPrefix . "Footprint" . $idSuffix, $this->_getSimpleMetric($stepResult, "carbon-footprint")['sustainable-web-design'] . 'g', $class); + $out .= $this->_bodyCell($idPrefix . "Footprint" . $idSuffix, $this->_getSimpleMetric($stepResult, "carbon-footprint")['sustainable-web-design'] . 'g', $class); } $out .= "\n"; @@ -576,10 +579,10 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) return $out; } - /** - * @param TestStepResult $stepResult - * @return string|null The $_REQUEST["end"] parameter if set and the run is the first view median run, null otherwise - */ + /** + * @param TestStepResult $stepResult + * @return string|null The $_REQUEST["end"] parameter if set and the run is the first view median run, null otherwise + */ private function getRequestEndParam($stepResult) { if (!$stepResult->isCachedRun() && array_key_exists('end', $_REQUEST)) { @@ -646,10 +649,10 @@ private function _getByteMetricInKbyte($step, $metric) return $value !== null ? number_format($value / 1024, 0) . "KB" : "-"; } - /** - * @param TestStepResult $stepResult - * @return string - */ + /** + * @param TestStepResult $stepResult + * @return string + */ private function _labelColumnText($stepResult) { $runNumber = $stepResult->getRunNumber(); From 0cf473d447e89af00b929236a8a627a6867e42c3 Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:21:16 +0530 Subject: [PATCH 4/7] Create thresholds.inc --- www/include/thresholds.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 www/include/thresholds.inc diff --git a/www/include/thresholds.inc b/www/include/thresholds.inc new file mode 100644 index 0000000000..34fc22e25b --- /dev/null +++ b/www/include/thresholds.inc @@ -0,0 +1,16 @@ + 2000, + 'TTBF_OK' => 1000, + 'FCP_POOR' => 5000, + 'FCP_OK' => 2000, + 'LCP_POOR' => 4000, + 'LCP_OK' => 2500, + 'CLS_POOR' => 0.25, + 'CLS_OK' => 0.1, + 'TBT_POOR' => 600, + 'TBT_OK' => 200, + 'RenderBlockingContentSizeCheck' => 0.5, + 'RenderBlockingContentPercentCheck' => 1, + 'RenderBlockingThirdPartyRequestsCheck' => 2 +); From 5a6c1f34decb7b765cf3dbab3f108fab6e3ebc9a Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:24:01 +0530 Subject: [PATCH 5/7] Update vitals.php --- www/vitals.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/www/vitals.php b/www/vitals.php index 61ba073d14..c1182c74b5 100644 --- a/www/vitals.php +++ b/www/vitals.php @@ -19,6 +19,7 @@ require_once INCLUDES_PATH . '/include/RequestDetailsHtmlSnippet.php'; require_once INCLUDES_PATH . '/include/RequestHeadersHtmlSnippet.php'; require_once INCLUDES_PATH . '/include/AccordionHtmlHelper.php'; +require_once INCLUDES_PATH . '/include/thresholds.inc'; $testInfo = TestInfo::fromFiles($testPath); $testRunResults = TestRunResults::fromFiles($testInfo, $run, $cached, null); @@ -171,6 +172,7 @@ function InsertWebVitalsHTML($stepResult) function InsertWebVitalsHTML_Summary($stepResult) { global $testRunResults; + global $MetricThresholds; echo '
'; // LCP $events = $stepResult->getMetric('largestPaints'); @@ -188,9 +190,9 @@ function InsertWebVitalsHTML_Summary($stepResult) } if (isset($lcp)) { $scoreClass = 'good'; - if ($lcp['time'] >= 4000) { + if ($lcp['time'] >= $MetricThresholds['LCP_POOR']) { $scoreClass = 'poor'; - } elseif ($lcp['time'] >= 2500) { + } elseif ($lcp['time'] >= $MetricThresholds['LCP_OK']) { $scoreClass = 'ok'; } echo "
"; @@ -229,9 +231,9 @@ function InsertWebVitalsHTML_Summary($stepResult) }); $cls = round($cls, 3); $scoreClass = 'good'; - if ($cls >= 0.25) { + if ($cls >= $MetricThresholds['CLS_POOR']) { $scoreClass = 'poor'; - } elseif ($cls >= 0.1) { + } elseif ($cls >= $MetricThresholds['CLS_OK']) { $scoreClass = 'ok'; } echo "
"; @@ -243,9 +245,9 @@ function InsertWebVitalsHTML_Summary($stepResult) $tbt = $stepResult->getMetric('TotalBlockingTime'); if (isset($tbt)) { $scoreClass = 'good'; - if ($tbt >= 600) { + if ($tbt >= $MetricThresholds['TBT_POOR']) { $scoreClass = 'poor'; - } elseif ($tbt >= 300) { + } elseif ($tbt >= $MetricThresholds['TBT_OK']) { $scoreClass = 'ok'; } echo "
"; From 73a1919cc661fb0ee301002843fc4226119fc2c0 Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:38:04 +0530 Subject: [PATCH 6/7] Update common.inc FCP check should be 3000 not 3 --- www/experiments/common.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/experiments/common.inc b/www/experiments/common.inc index aba4f5611e..71eb339dca 100644 --- a/www/experiments/common.inc +++ b/www/experiments/common.inc @@ -299,7 +299,7 @@ foreach ($assessment as $key => $cat) { } elseif ( $numRecommended > 2 // and it's the quickness category and fcp is reasonably slow - && ($key !== "Quick" || $key === "Quick" && $fcpCheck > 3 ) + && ($key !== "Quick" || $key === "Quick" && $fcpCheck > 3000 ) && ($key !== "Resilient" || $key === "Resilient" && $blocking3pReqs > 0 ) && ($key !== "Usable" || $key === "Usable" && ((isset($cls) && $cls > 0) || (isset($tbtCheck) && $tbtCheck > 2)) ) ) { From 18d06c2372ff856484ebee96ca769ac2509a3945 Mon Sep 17 00:00:00 2001 From: claud-io Date: Mon, 19 Aug 2024 11:29:43 +0200 Subject: [PATCH 7/7] removed FID --- www/include/CrUX.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/www/include/CrUX.php b/www/include/CrUX.php index dd96e8d228..5d93bd6433 100644 --- a/www/include/CrUX.php +++ b/www/include/CrUX.php @@ -71,8 +71,6 @@ function InsertCruxHTML($fvRunResults, $metric = '') InsertCruxMetricHTML($pageData, 'chromeUserTiming.LargestContentfulPaint', 'largest_contentful_paint', 'Largest Contentful Paint', 'LCP'); } elseif ($metric == 'cls') { InsertCruxMetricHTML($pageData, 'chromeUserTiming.CumulativeLayoutShift', 'cumulative_layout_shift', 'Cumulative Layout Shift', 'CLS'); - } elseif ($metric == 'fid') { - InsertCruxMetricHTML($pageData, null, 'first_input_delay', 'First Input Delay', 'FID'); } elseif ($metric == 'ttfb') { InsertCruxMetricHTML($pageData, 'TTFB', 'experimental_time_to_first_byte', 'Time to First Byte', 'TTFB'); } elseif ($metric == 'inp') { @@ -80,7 +78,6 @@ function InsertCruxHTML($fvRunResults, $metric = '') } elseif ($metric == 'cwv') { InsertCruxMetricHTML($pageData, 'chromeUserTiming.LargestContentfulPaint', 'largest_contentful_paint', 'Largest Contentful Paint', 'LCP'); InsertCruxMetricHTML($pageData, 'chromeUserTiming.CumulativeLayoutShift', 'cumulative_layout_shift', 'Cumulative Layout Shift', 'CLS'); - InsertCruxMetricHTML($pageData, null, 'first_input_delay', 'First Input Delay', 'FID'); }