/**
 * Parse the page data and load the optimization-specific details for one step
 *
 * @param TestInfo $testInfo Test information
 * @param TestStepResult $testStepResult Results of the step to get the grades for
 * @return array|null An array with all labels, scores, grades, weights, etc per score
 */
function getOptimizationGradesForStep($testInfo, $testStepResult)
{
    // The function getOptimizationGradesForRun is more powerful as it can compute averages.
    // With one step, it will do exactly what we want, so we create an artificial run
    $singlestepRunResult = TestRunResults::fromStepResults($testInfo, $testStepResult->getRunNumber(), $testStepResult->isCachedRun(), array($testStepResult));
    return getOptimizationGradesForRun($singlestepRunResult);
}
Ejemplo n.º 2
0
 /**
  * Gather all of the data that we collect for a single run
  *
  * @param TestStepResult $testStepResult
  * @return array Array with run information which can be serialized as JSON
  */
 private function stepDataArray($testStepResult)
 {
     if (!$testStepResult) {
         return null;
     }
     $ret = $testStepResult->getRawResults();
     $run = $testStepResult->getRunNumber();
     $cached = $testStepResult->isCachedRun();
     $step = $testStepResult->getStepNumber();
     $localPaths = new TestPaths($this->testInfo->getRootDirectory(), $run, $cached, $step);
     $nameOnlyPaths = new TestPaths("", $run, $cached, $step);
     $urlGenerator = UrlGenerator::create(false, $this->urlStart, $this->testInfo->getId(), $run, $cached, $step);
     $friendlyUrlGenerator = UrlGenerator::create(true, $this->urlStart, $this->testInfo->getId(), $run, $cached, $step);
     $urlPaths = new TestPaths($this->urlStart . substr($this->testInfo->getRootDirectory(), 1), $run, $cached, $step);
     $basic_results = $this->hasInfoFlag(self::BASIC_INFO_ONLY);
     if (!$basic_results && $this->fileHandler->gzFileExists($localPaths->pageSpeedFile())) {
         $ret['PageSpeedScore'] = $testStepResult->getPageSpeedScore();
         $ret['PageSpeedData'] = $urlGenerator->getGZip($nameOnlyPaths->pageSpeedFile());
     }
     $ret['pages'] = array();
     $ret['pages']['details'] = $urlGenerator->resultPage("details");
     $ret['pages']['checklist'] = $urlGenerator->resultPage("performance_optimization");
     $ret['pages']['breakdown'] = $urlGenerator->resultPage("breakdown");
     $ret['pages']['domains'] = $urlGenerator->resultPage("domains");
     $ret['pages']['screenShot'] = $urlGenerator->resultPage("screen_shot");
     $ret['thumbnails'] = array();
     $ret['thumbnails']['waterfall'] = $friendlyUrlGenerator->thumbnail("waterfall.png");
     $ret['thumbnails']['checklist'] = $friendlyUrlGenerator->thumbnail("optimization.png");
     $ret['thumbnails']['screenShot'] = $friendlyUrlGenerator->thumbnail("screen.png");
     $ret['images'] = array();
     $ret['images']['waterfall'] = $friendlyUrlGenerator->generatedImage("waterfall");
     $ret['images']['connectionView'] = $friendlyUrlGenerator->generatedImage("connection");
     $ret['images']['checklist'] = $friendlyUrlGenerator->optimizationChecklistImage();
     $ret['images']['screenShot'] = $urlGenerator->getFile($nameOnlyPaths->screenShotFile());
     if ($this->fileHandler->fileExists($localPaths->screenShotPngFile())) {
         $ret['images']['screenShotPng'] = $urlGenerator->getFile($nameOnlyPaths->screenShotPngFile());
     }
     $ret['rawData'] = array();
     if ($this->fileHandler->gzFileExists($localPaths->devtoolsScriptTimingFile())) {
         $ret['rawData']['scriptTiming'] = $urlGenerator->getGZip($nameOnlyPaths->devtoolsScriptTimingFile());
     }
     $ret['rawData']['headers'] = $urlPaths->headersFile();
     $ret['rawData']['pageData'] = $urlPaths->pageDataFile();
     $ret['rawData']['requestsData'] = $urlPaths->requestDataFile();
     $ret['rawData']['utilization'] = $urlPaths->utilizationFile();
     if ($this->fileHandler->fileExists($localPaths->bodiesFile())) {
         $ret['rawData']['bodies'] = $urlPaths->bodiesFile();
     }
     if ($this->fileHandler->gzFileExists($localPaths->devtoolsTraceFile())) {
         $ret['rawData']['trace'] = $urlGenerator->getGZip($nameOnlyPaths->devtoolsTraceFile() . ".gz");
     }
     if (!$basic_results) {
         $ret = array_merge($ret, $this->getAdditionalInfoArray($testStepResult, $urlGenerator, $nameOnlyPaths));
     }
     return $ret;
 }
 /**
  * @param TestStepResult $stepResult
  * @return string Markup with label
  */
 private function _getResultLabel($stepResult)
 {
     $out = "";
     $error = $this->testInfo->getRunError($stepResult->getRunNumber(), $stepResult->isCachedRun());
     if ($error) {
         $out .= '<br>(Test Error: ' . htmlspecialchars($error) . ')';
     }
     $result = $stepResult->getMetric("result");
     $loadTime = $stepResult->getMetric("loadTime");
     if ($result !== null && $result !== 0 && $result !== 99999) {
         $out .= '<br>(Error: ' . LookupError($result) . ')';
     } else {
         if ($loadTime !== null) {
             $out .= '<br>(' . number_format($loadTime / 1000.0, 3) . 's)';
         }
     }
     return $out;
 }
Ejemplo n.º 4
0
 /**
  * @param TestStepResult $stepResult
  * @return string
  */
 private function _labelColumnText($stepResult)
 {
     $runNumber = $stepResult->getRunNumber();
     if (!$this->isMultistep) {
         return $this->_rvLabel($stepResult->isCachedRun(), $runNumber);
     }
     $label = FitText($stepResult->readableIdentifier(), 30);
     if ($this->enableLabelLinks) {
         $label = "<a href='#run" . $runNumber . "_step" . $stepResult->getStepNumber() . "'>" . $label . "</a>";
     }
     return $label;
 }
Ejemplo n.º 5
0
 /**
  * @param TestStepResult $testResult Result Data
  */
 private function printPageSpeedData($testResult)
 {
     $testRoot = $this->testInfo->getRootDirectory();
     $localPaths = new TestPaths($testRoot, $testResult->getRunNumber(), $testResult->isCachedRun());
     $urlPaths = new TestPaths($this->baseUrl . substr($testRoot, 1), $testResult->isCachedRun());
     if ($this->fileHandler->gzFileExists($localPaths->pageSpeedFile())) {
         echo "<PageSpeedData>" . $urlPaths->pageSpeedFile() . "</PageSpeedData>\n";
     }
 }