/** * Send back the data for a batch test (just the list of test ID's) * * @param mixed $id * @param mixed $testPath */ function BatchResult($id, $testPath) { header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; echo "<response>"; if (strlen($_REQUEST['r'])) { echo "<requestId>{$_REQUEST['r']}</requestId>"; } $tests = null; if (gz_is_file("{$testPath}/bulk.json")) { $tests = json_decode(gz_file_get_contents("{$testPath}/bulk.json"), true); } elseif (gz_is_file("{$testPath}/tests.json")) { $legacyData = json_decode(gz_file_get_contents("{$testPath}/tests.json"), true); $tests = array(); $tests['variations'] = array(); $tests['urls'] = array(); foreach ($legacyData as &$legacyTest) { $tests['urls'][] = array('u' => $legacyTest['url'], 'id' => $legacyTest['id']); } } if (count($tests['urls'])) { echo "<statusCode>200</statusCode>"; echo "<statusText>Ok</statusText>"; if (strlen($_REQUEST['r'])) { echo "<requestId>{$_REQUEST['r']}</requestId>"; } $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); echo "<data>"; foreach ($tests['urls'] as &$test) { echo "<test>"; echo "<testId>{$test['id']}</testId>"; echo "<testUrl>" . xml_entities($test['u']) . "</testUrl>"; echo "<xmlUrl>http://{$host}{$uri}/xmlResult/{$test['id']}/</xmlUrl>"; echo "<userUrl>http://{$host}{$uri}/result/{$test['id']}/</userUrl>"; echo "<summaryCSV>http://{$host}{$uri}/result/{$test['id']}/page_data.csv</summaryCSV>"; echo "<detailCSV>http://{$host}{$uri}/result/{$test['id']}/requests.csv</detailCSV>"; echo "</test>"; // go through all of the variations as well foreach ($test['v'] as $variationIndex => $variationId) { echo "<test>"; echo "<testId>{$variationId}</testId>"; echo "<testUrl>" . xml_entities(CreateUrlVariation($test['u'], $tests['variations'][$variationIndex]['q'])) . "</testUrl>"; echo "<xmlUrl>http://{$host}{$uri}/xmlResult/{$variationId}/</xmlUrl>"; echo "<userUrl>http://{$host}{$uri}/result/{$variationId}/</userUrl>"; echo "<summaryCSV>http://{$host}{$uri}/result/{$variationId}/page_data.csv</summaryCSV>"; echo "<detailCSV>http://{$host}{$uri}/result/{$variationId}/requests.csv</detailCSV>"; echo "</test>"; } } echo "</data>"; } else { echo "<statusCode>404</statusCode>"; echo "<statusText>Invalid Test ID: {$id}</statusText>"; echo "<data>"; echo "</data>"; } echo "</response>"; }
$testData['runs'] = max(1, $testData['runs'] - $testData['discard']); $testData['discard'] = 0; } } if ($entry['s']) { $testData['script'] = $entry['s']; } ValidateParameters($testData, $locations, $error, $entry['u']); $entry['id'] = CreateTest($testData, $entry['u']); if ($entry['id']) { $entry['v'] = array(); foreach ($bulk['variations'] as $variation_index => &$variation) { if (strlen($test['label']) && strlen($variation['l'])) { $test['label'] .= ' - ' . $variation['l']; } $url = CreateUrlVariation($entry['u'], $variation['q']); if ($url) { ValidateParameters($testData, $locations, $error, $url); $entry['v'][$variation_index] = CreateTest($testData, $url); } } $testCount++; } } // write out the list of urls and the test ID for each if ($testCount) { $path = GetTestPath($test['id']); gz_file_put_contents("./{$path}/bulk.json", json_encode($bulk)); } else { $error = 'Urls could not be submitted for testing'; }
echo "\"{$count}\","; if ($use_median_run) { $median_run = GetMedianRun($pageData, $cacheVal, $median_metric); echo "\"{$median_run}\","; } foreach ($metrics as $metric => $metricLabel) { if ($use_median_run) { echo "\"{$pageData[$median_run][$cacheVal][$metric]}\","; } else { CalculateAggregateStats($pageData, $cacheVal, $metric, $median, $avg, $stdDev); echo "\"{$median}\",\"{$avg}\",\"{$stdDev}\","; } } } foreach ($tests['variations'] as $variationIndex => &$variation) { $urlVariation = CreateUrlVariation($url, $variation['q']); echo "\"{$urlVariation}\","; $id = $test['v'][$variationIndex]; RestoreTest($id); GetTestStatus($id); $testPath = './' . GetTestPath($id); $pageData = loadAllPageData($testPath); for ($cacheVal = 0; $cacheVal <= $cached; $cacheVal++) { if (count($pageData)) { $count = CountSuccessfulTests($pageData, $cacheVal); echo "\"{$count}\","; if ($use_median_run) { $median_run = GetMedianRun($pageData, $cacheVal, $median_metric); echo "\"{$median_run}\","; } foreach ($metrics as $metric => $metricLabel) {