/** * Parse the page data and load the optimization-specific details for a complete run * * @param TestRunResults $testRunResults Results of the run to get the grades for * @return array|null An array with all labels, scores, grades, weights, etc per score */ function getOptimizationGradesForRun($testRunResults) { if (!isset($testRunResults)) { return null; } $scores = array(); $scores['keep-alive'] = $testRunResults->averageMetric('score_keep-alive'); $scores['gzip'] = $testRunResults->averageMetric('score_gzip'); $scores['image_compression'] = $testRunResults->averageMetric('score_compress'); $scores['caching'] = $testRunResults->averageMetric('score_cache'); $scores['combine'] = $testRunResults->averageMetric('score_combine'); $scores['cdn'] = $testRunResults->averageMetric('score_cdn'); $scores['cookies'] = $testRunResults->averageMetric('score_cookies'); $scores['minify'] = $testRunResults->averageMetric('score_minify'); $scores['e-tags'] = $testRunResults->averageMetric('score_etags'); $scores['progressive_jpeg'] = $testRunResults->averageMetric('score_progressive_jpeg'); $numTTFBScores = 0; $sumTTFBScores = 0.0; for ($i = 1; $i <= $testRunResults->countSteps(); $i++) { $stepResult = $testRunResults->getStepResult($i); $pageData = $stepResult->getRawResults(); $ttfb = (int) $pageData['TTFB']; $latency = isset($test['testinfo']['latency']) ? $test['testinfo']['latency'] : null; $ttfbScore = gradeTTFBForStep($ttfb, $latency, $stepResult->createTestPaths(), $target); if (isset($ttfbScore)) { $numTTFBScores++; $sumTTFBScores += $ttfbScore; } } if ($numTTFBScores > 0) { $scores['ttfb'] = $sumTTFBScores / $numTTFBScores; } return createGradeArray($scores); }
/** * @param TestRunResults $testRunResults The run results to generate quicklinks for */ function printQuicklinks($testRunResults) { echo '<a name="quicklinks"><h1>Quicklinks</h1></a>'; echo '<div style="text-align: center;"><table class="pretty" id="quicklinks_table">'; echo '<tbody>'; for ($i = 1; $i <= $testRunResults->countSteps(); $i++) { $class = $i % 2 == 0 ? " class='even'" : ""; echo '<tr' . $class . '>'; echo '<th>' . $testRunResults->getStepResult($i)->readableIdentifier() . '</th>'; echo '<td><a href="#step_' . $i . '">Screen Shots</a></td>'; echo '</tr>'; } echo '</tbody>'; echo "</table></div>"; }
/** * @param TestRunResults $runResult Result of this run */ public function printRun($runResult) { if (empty($runResult)) { return; } $testResult = $runResult->getStepResult(1); $numSteps = $runResult->countSteps(); $this->printViewRootStartTag($testResult->isCachedRun()); $this->printTester($runResult->getRunNumber()); echo "<numSteps>" . $numSteps . "</numSteps>\n"; if ($this->forceMultistep || $numSteps > 1) { for ($step = 1; $step <= $numSteps; $step++) { $testStepResult = $runResult->getStepResult($step); $eventName = empty($testStepResult) ? "" : $testStepResult->getEventName(); echo "<step>\n"; echo "<id>" . $step . "</id>"; echo "<eventName>" . $eventName . "</eventName>"; $this->printStepResults($testStepResult); echo "</step>\n"; } } else { $this->printStepResults($runResult->getStepResult(1)); } $this->printViewRootEndTag($testResult->isCachedRun()); }