本文整理汇总了PHP中GetTestStatus函数的典型用法代码示例。如果您正苦于以下问题:PHP GetTestStatus函数的具体用法?PHP GetTestStatus怎么用?PHP GetTestStatus使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTestStatus函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckBenchmarkStatus
/**
* Check the status of any pending tests
*
* @param mixed $state
*/
function CheckBenchmarkStatus($benchmark, &$state)
{
global $logFile;
if ($state['running']) {
$start_time = $state['last_run'];
if (!is_dir("./results/benchmarks/{$benchmark}/data")) {
mkdir("./results/benchmarks/{$benchmark}/data", 0777, true);
}
$dataFile = "./results/benchmarks/{$benchmark}/data/" . gmdate('Ymd_Hi', $start_time) . '.json';
logMsg("Data File: {$dataFile}", "./log/{$logFile}", true);
$updated = 0;
if (gz_is_file($dataFile)) {
$data = json_decode(gz_file_get_contents($dataFile), true);
logMsg("Loaded " . count($data) . " existing records", "./log/{$logFile}", true);
} else {
$data = array();
logMsg("Data file doesn't exist, starting fresh", "./log/{$logFile}", true);
}
$done = true;
$total_tests = count($state['tests']);
$pending_tests = 0;
foreach ($state['tests'] as &$test) {
if (!$test['completed']) {
$status = GetTestStatus($test['id'], true);
$now = time();
if ($status['statusCode'] >= 400) {
logMsg("Test {$test['id']} : Failed - {$status['statusText']}", "./log/{$logFile}", true);
$test['completed'] = $now;
} elseif ($status['statusCode'] == 200) {
logMsg("Test {$test['id']} : Completed", "./log/{$logFile}", true);
if (array_key_exists('completeTime', $status) && $status['completeTime']) {
$test['completed'] = $status['completeTime'];
} elseif (array_key_exists('startTime', $status) && $status['startTime']) {
$test['completed'] = $status['startTime'];
} else {
$test['completed'] = $now;
}
} else {
$pending_tests++;
$done = false;
logMsg("Test {$test['id']} : {$status['statusText']}", "./log/{$logFile}", true);
}
// collect the test data and archive the test as we get each result
if ($test['completed']) {
$updated++;
CollectResults($test, $data);
if (ArchiveTest($test['id'])) {
logMsg("Test {$test['id']} : Archived", "./log/{$logFile}", true);
$path = GetTestPath($test['id']);
if (strlen($path)) {
delTree($path);
}
}
}
}
}
if ($updated) {
logMsg("Data updated for for {$updated} tests, total data rows: " . count($data), "./log/{$logFile}", true);
gz_file_put_contents($dataFile, json_encode($data));
} else {
logMsg("No test data updated", "./log/{$logFile}", true);
}
$now = time();
$elapsed = $now > $start_time ? $now - $start_time : 0;
if ($elapsed > 172800) {
// kill it if it has been running for 2 days
$done = true;
}
if ($done) {
logMsg("Benchmark '{$benchmark}' is finished after running for {$elapsed} seconds", "./log/{$logFile}", true);
$state['runs'][] = $start_time;
$state['running'] = false;
$state['needs_aggregation'] = true;
unset($state['tests']);
} else {
logMsg("'{$benchmark}' is waiting for {$pending_tests} of {$total_tests} tests after {$elapsed} seconds", "./log/{$logFile}", true);
}
logMsg("Done checking status", "./log/{$logFile}", true);
}
}
示例2: array
<?php
require_once 'common.inc';
require_once 'page_data.inc';
require_once 'testStatus.inc';
require_once 'video/visualProgress.inc.php';
require_once 'domains.inc';
require_once 'breakdown.inc';
require_once 'devtools.inc.php';
require_once 'archive.inc';
if (array_key_exists('batch', $test['test']) && $test['test']['batch']) {
include 'resultBatch.inc';
} else {
$ret = array('data' => GetTestStatus($id));
$ret['statusCode'] = $ret['data']['statusCode'];
$ret['statusText'] = $ret['data']['statusText'];
if ($ret['statusCode'] == 200) {
$ret['data'] = GetTestResult($id);
}
json_response($ret);
}
/**
* Gather all of the data for a given test and return it as an array
*
* @param mixed $id
*/
function GetTestResult($id)
{
global $url;
global $median_metric;
$testPath = './' . GetTestPath($id);
示例3: BatchResult
require_once 'page_data.inc';
require_once 'testStatus.inc';
require_once 'video/visualProgress.inc.php';
require_once 'domains.inc';
require_once 'breakdown.inc';
require_once 'devtools.inc.php';
// see if we are sending abbreviated results
$pagespeed = 0;
if (array_key_exists('pagespeed', $_REQUEST)) {
$pagespeed = (int) $_REQUEST['pagespeed'];
}
if (isset($test['test']) && $test['test']['batch']) {
BatchResult($id, $testPath);
} else {
// see if the test is actually finished
$status = GetTestStatus($id);
if (isset($test['test']['completeTime'])) {
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$path = substr($testPath, 1);
$pageData = loadAllPageData($testPath);
$msLoad = microtime(true);
// if we don't have an url, try to get it from the page results
if (!strlen($url)) {
$url = $pageData[1][0]['URL'];
}
header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<response>\n";
echo "<statusCode>200</statusCode>\n";
echo "<statusText>Ok</statusText>\n";
示例4: foreach
}
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) {
if ($use_median_run) {
echo "\"{$pageData[$median_run][$cacheVal][$metric]}\",";
} else {
CalculateAggregateStats($pageData, $cacheVal, $metric, $median, $avg, $stdDev);
示例5: explode
$searches = explode(',', $_REQUEST['searches']);
}
$maxReqs = 0;
if (isset($_REQUEST['maxReqs']) && strlen($_REQUEST['maxReqs'])) {
$maxReqs = $_REQUEST['maxReqs'];
}
header("Content-disposition: attachment; filename={$id}_headersMatch.csv");
header("Content-type: text/csv");
// list of metrics that will be produced
// for each of these, the median, average and std dev. will be calculated
echo "\"Test ID\",\"Found\"\r\n";
// and now the actual data
foreach ($testIds as &$testId) {
$cached = 0;
RestoreTest($testId);
GetTestStatus($testId);
$testPath = './' . GetTestPath($testId);
$pageData = loadAllPageData($testPath);
$medianRun = GetMedianRun($pageData, $cached);
$secured = 0;
$haveLocations = 1;
$requests = getRequests($testId, $testPath, $medianRun, $cached, $secure, $haveLocations, false, true);
// Flag indicating if we matched
$matched = array();
$nSearches = count($searches);
$nRecords = count($requests);
if ($nRecords > $maxReqs && $maxReqs != 0) {
$nRecords = $maxReqs;
}
for ($rec = 0; $rec < $nRecords; $rec++) {
$r = $requests[$rec];
示例6: GetTestStatus
}
}
if (array_key_exists('testsExpected', $status)) {
$ret['data']['testsExpected'] += $status['testsExpected'];
}
if (array_key_exists('testsCompleted', $status)) {
$ret['data']['testsCompleted'] += $status['testsCompleted'];
}
}
}
if ($ret['statusCode'] >= 100 && $ret['statusCode'] < 200 && $ret['data']['testsCompleted'] > 0 && $ret['data']['testsExpected'] > 1) {
$ret['statusCode'] = 100;
$ret['statusText'] = "Completed {$ret['data']['testsCompleted']} of {$ret['data']['testsExpected']} tests";
}
} else {
$ret['data'] = GetTestStatus($id, $position);
$ret['statusCode'] = $ret['data']['statusCode'];
$ret['statusText'] = $ret['data']['statusText'];
}
// spit out the response in the correct format
if ($_REQUEST['f'] == 'xml') {
header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<response>\n";
foreach ($ret as $key => &$val) {
echo "<{$key}>";
if ($key == 'data') {
echo "\n";
foreach ($val as $k => $v) {
echo "<{$k}>{$v}</{$k}>\n";
}
示例7: CheckTest
/**
* Check the given log file for all tests that match
*
* @param mixed $logFile
* @param mixed $match
*/
function CheckTest($testPath, $id, $elapsedDays)
{
global $archiveCount;
global $deleted;
global $kept;
global $log;
global $MIN_DAYS;
$logLine = "{$id} : ";
echo "\rArc:{$archiveCount}, Del:{$deleted}, Kept:{$kept}, Checking:" . str_pad($id, 45);
$delete = false;
if (!is_file("{$testPath}/testinfo.ini") && !is_file("{$testPath}/testinfo.json.gz") && !is_file("{$testPath}/testinfo.json")) {
$delete = true;
} else {
$elapsed = TestLastAccessed($id);
if (isset($elapsed)) {
if ($elapsed >= $MIN_DAYS) {
if (ArchiveTest($id)) {
$archiveCount++;
$logLine .= "Archived";
if (VerifyArchive($id) || $elapsed >= 30) {
$delete = true;
}
} else {
if ($elapsed < 60) {
$status = GetTestStatus($id, false);
if ($status['statusCode'] >= 400 || $status['statusCode'] == 102 && $status['remote'] && $elapsed > 1) {
$delete = true;
}
} elseif ($elapsedDays > 10) {
$logLine .= "Old test, Failed to archive, deleting";
$delete = true;
} else {
$logLine .= "Failed to archive";
}
}
} else {
$logLine .= "Last Accessed {$elapsed} days";
}
} else {
$delete = true;
}
}
if ($delete) {
delTree("{$testPath}/");
$deleted++;
$logLine .= " Deleted";
} else {
$kept++;
}
if ($log) {
$logLine .= "\n";
fwrite($log, $logLine);
}
}