当前位置: 首页>>代码示例>>PHP>>正文


PHP GetTestPath函数代码示例

本文整理汇总了PHP中GetTestPath函数的典型用法代码示例。如果您正苦于以下问题:PHP GetTestPath函数的具体用法?PHP GetTestPath怎么用?PHP GetTestPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetTestPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ReprocessVideo

/**
* Re-process all of the video for an existing test
* 
* @param mixed $id
*/
function ReprocessVideo($id)
{
    $testPath = './' . GetTestPath($id);
    if (is_dir($testPath)) {
        $lock = LockTest($id);
        if (isset($lock)) {
            $cacheFiles = glob("{$testPath}/*.dat.gz");
            if ($cacheFiles && is_array($cacheFiles) && count($cacheFiles)) {
                foreach ($cacheFiles as $cacheFile) {
                    unlink($cacheFile);
                }
            }
            $videoFiles = glob("{$testPath}/*.mp4");
            if ($videoFiles && is_array($videoFiles) && count($videoFiles)) {
                foreach ($videoFiles as $video) {
                    if (preg_match('/^.*\\/(?P<run>[0-9]+)(?P<cached>_Cached)?_video\\.mp4$/i', $video, $matches)) {
                        $run = $matches['run'];
                        $cached = array_key_exists('cached', $matches) ? 1 : 0;
                        $videoDir = "{$testPath}/video_{$run}";
                        if ($cached) {
                            $videoDir .= '_cached';
                        }
                        delTree($videoDir, false);
                        ProcessAVIVideo($id, $testPath, $run, $cached);
                    }
                }
            }
            UnlockTest($lock);
        }
    }
}
开发者ID:JHand93,项目名称:WebPerformanceTestSuite,代码行数:36,代码来源:avi2frames.inc.php

示例2: CheckLog

/**
* Check the given log file for all tests that match
* 
* @param mixed $logFile
* @param mixed $match
*/
function CheckLog($logFile, $match)
{
    global $count;
    echo "\r({$count}): Checking {$logFile}";
    $file = file_get_contents($logFile);
    if (stripos($file, $match) !== false) {
        $lines = explode("\n", $file);
        $file = '';
        foreach ($lines as $line) {
            if (stripos($line, $match) !== false) {
                $parseLine = str_replace("\t", "\t ", $line);
                $parts = explode("\t", $parseLine);
                $testId = trim($parts[4]);
                $testPath = './' . GetTestPath($testId);
                if (strlen($testPath)) {
                    delTree($testPath);
                    usleep(100000);
                    // give the system a chance to breathe
                    $count++;
                    echo "\r({$count}): Checking {$logFile}";
                }
            } else {
                $file .= $line . "\n";
            }
        }
        // rewrite the trimmed file
        file_put_contents($logFile, $file);
    } else {
        unset($file);
    }
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:37,代码来源:prune.php

示例3: GetLastFrameHistogram

function GetLastFrameHistogram($test, $run)
{
    $histogram = null;
    $videoPath = './' . GetTestPath($test) . "/video_{$run}";
    $files = glob("{$videoPath}/*.jpg");
    if ($files) {
        rsort($files);
        $lastFrame = $files[0];
        $histogram = GetImageHistogram($lastFrame);
    }
    return $histogram;
}
开发者ID:sethblanchard,项目名称:webpagetest,代码行数:12,代码来源:compareFrames.php

示例4: GetLastFrameHistogram

function GetLastFrameHistogram($test, $run)
{
    $histogram = null;
    $testPath = GetTestPath($test);
    $videoPath = "./{$testPath}/video_{$run}";
    $files = glob("{$videoPath}/*.jpg");
    if ($files) {
        rsort($files);
        $lastFrame = $files[0];
        if (gz_is_file("{$testPath}/{$run}.0.histograms.json")) {
            $histograms = json_decode(gz_file_get_contents("{$testPath}/{$run}.0.histograms.json"), true);
        }
        $histogram = GetImageHistogram($lastFrame, null, $histograms);
    }
    return $histogram;
}
开发者ID:nstanard,项目名称:webpagetest,代码行数:16,代码来源:compareFrames.php

示例5: ResubmitTest

function ResubmitTest($id)
{
    echo "{$id} - Resubmitting...";
    $testPath = './' . GetTestPath($id);
    if (gz_is_file("{$testPath}/testinfo.json")) {
        $test = json_decode(gz_file_get_contents("{$testPath}/testinfo.json"), true);
        if (array_key_exists('job_file', $test) && array_key_exists('location', $test) && is_file("{$testPath}/test.job")) {
            if ($lock = LockLocation($test['location'])) {
                if (copy("{$testPath}/test.job", $test['job_file'])) {
                    $files = scandir($testPath);
                    foreach ($files as $file) {
                        if ($file != '.' && $file != '..' && strncasecmp($file, 'test', 4)) {
                            if (is_file("{$testPath}/{$file}")) {
                                unlink("{$testPath}/{$file}");
                            } elseif (is_dir("{$testPath}/{$file}")) {
                                delTree("{$testPath}/{$file}");
                            }
                        }
                    }
                    AddJobFile($test['workdir'], $test['job'], $test['priority'], false);
                    $test['started'] = time();
                    unset($test['completeTime']);
                    gz_file_put_contents("{$testPath}/testinfo.json", json_encode($test));
                    echo "OK";
                } else {
                    echo "Failed to copy job file";
                }
                UnlockLocation($lock);
            } else {
                echo "Failed to lock location";
            }
        } else {
            echo "Invalid test";
        }
    } else {
        echo "Test not found";
    }
    echo "\n";
}
开发者ID:risyasin,项目名称:webpagetest,代码行数:39,代码来源:resubmit.php

示例6: explode

<?php

// Generate a PNG image that is the difference of two existing images
include 'common.inc';
require_once 'draw.inc';
// figure out the paths to the actual images
$parts = explode('/', $_REQUEST['ref']);
if (count($parts) == 2) {
    $ref = './' . GetTestPath($parts[0]) . '/' . $parts[1];
}
$parts = explode('/', $_REQUEST['cmp']);
if (count($parts) == 2) {
    $cmp = './' . GetTestPath($parts[0]) . '/' . $parts[1];
}
$ok = false;
if (isset($ref) && isset($cmp) && is_file($ref) && is_file($cmp)) {
    $refImg = imagecreatefrompng($ref);
    $cmpImg = imagecreatefrompng($cmp);
    if ($refImg !== FALSE && $cmpImg !== FALSE) {
        $refWidth = imagesx($refImg);
        $refHeight = imagesy($refImg);
        $cmpWidth = imagesx($cmpImg);
        $cmpHeight = imagesy($cmpImg);
        if ($refWidth && $refHeight && $cmpWidth && $cmpHeight) {
            $width = max($refWidth, $cmpWidth);
            $height = max($refHeight, $cmpHeight);
            $im = imagecreate($width, $height);
            if ($im !== FALSE) {
                $black = GetColor($im, 0, 0, 0);
                $white = GetColor($im, 255, 255, 255);
                imagefilledrectangle($im, 0, 0, $width, $height, $black);
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:31,代码来源:imgdiff.php

示例7: header

}
$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];
        if (isset($r['headers']) && isset($r['headers']['response'])) {
开发者ID:it114,项目名称:webpagetest,代码行数:31,代码来源:headersMatch.php

示例8: trim

         if ($p[0] == 'r') {
             $test['run'] = (int) $p[1];
         }
         if ($p[0] == 'l') {
             $test['label'] = $p[1];
         }
         if ($p[0] == 'c') {
             $test['cached'] = (int) $p[1];
         }
         if ($p[0] == 'e') {
             $test['end'] = trim($p[1]);
         }
     }
 }
 RestoreTest($test['id']);
 $test['path'] = GetTestPath($test['id']);
 $test['pageData'] = loadAllPageData($test['path']);
 $info = GetTestInfo($test['id']);
 if ($info) {
     if (array_key_exists('discard', $info) && $info['discard'] >= 1 && array_key_exists('priority', $info) && $info['priority'] >= 1) {
         $defaultInterval = 100;
     }
     $test['url'] = $info['url'];
 }
 $testInfo = parse_ini_file("./{$test['path']}/testinfo.ini", true);
 if ($testInfo !== FALSE) {
     if (array_key_exists('test', $testInfo) && array_key_exists('location', $testInfo['test'])) {
         $test['location'] = $testInfo['test']['location'];
     }
     if (isset($testInfo['test']) && isset($testInfo['test']['completeTime'])) {
         $test['done'] = true;
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:filmstrip.inc.php

示例9: getTargetTTFB

/**
* Determine the target TTFB for the given test
*
* @param mixed $pageData
* @param mixed $test
* @param mixed $id
* @param mixed $run
*/
function getTargetTTFB(&$pageData, &$test, $id, $run, $cached)
{
    $target = NULL;
    $rtt = null;
    if (isset($test['testinfo']['latency'])) {
        $rtt = (int) $test['testinfo']['latency'];
    }
    // load the object data (unavoidable, we need the socket connect time to the first host)
    require_once 'object_detail.inc';
    $testPath = './' . GetTestPath($id);
    $secure = false;
    $haveLocations;
    $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false);
    if (count($requests)) {
        // figure out what the RTT is to the server (take the connect time from the first request unless it is over 3 seconds)
        $connect_ms = $requests[0]['connect_ms'];
        if (isset($rtt) && (!isset($connect_ms) || $connect_ms > 3000)) {
            $rtt += 100;
        } else {
            $rtt = $connect_ms;
        }
        if (isset($rtt)) {
            $ssl_ms = 0;
            if ($requests[0]['is_secure'] && (int) $requests[0]['ssl_ms'] > 0) {
                $ssl_ms = $requests[0]['ssl_ms'];
            }
            // RTT's: DNS + Socket Connect + HTTP Request
            $target = $rtt * 3 + $ssl_ms;
        }
    }
    return $target;
}
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:40,代码来源:optimization_detail.inc.php

示例10: getTargetTTFB

/**
* Determine the target TTFB for the given test
*
* @param mixed $pageData
* @param mixed $test
* @param mixed $id
* @param mixed $run
*/
function getTargetTTFB(&$pageData, &$test, $id, $run, $cached)
{
    $target = NULL;
    $rtt = 0;
    if (isset($test['testinfo']['latency'])) {
        $rtt = (int) $test['testinfo']['latency'];
    }
    // load the object data (unavoidable, we need the socket connect time to the first host)
    require_once 'object_detail.inc';
    $testPath = './' . GetTestPath($id);
    $secure = false;
    $haveLocations;
    $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false);
    if (count($requests)) {
        // figure out what the RTT is to the server (take the connect time from the first request unless it is over 3 seconds)
        if (isset($requests[0]['connect_start']) && $requests[0]['connect_start'] >= 0 && isset($requests[0]['connect_end']) && $requests[0]['connect_end'] > $requests[0]['connect_start']) {
            $rtt = $requests[0]['connect_end'] - $requests[0]['connect_start'];
        } else {
            $connect_ms = $requests[0]['connect_ms'];
            if ($rtt > 0 && (!isset($connect_ms) || $connect_ms > 3000 || $connect_ms < 0)) {
                $rtt += 100;
            } else {
                $rtt = $connect_ms;
            }
        }
        // allow for a minimum of 100ms for the RTT
        $rtt = max($rtt, 100);
        $ssl_ms = 0;
        $i = 0;
        while (isset($requests[$i])) {
            if (isset($requests[$i]['contentType']) && (stripos($requests[$i]['contentType'], 'ocsp') !== false || stripos($requests[$i]['contentType'], 'crl') !== false)) {
                $i++;
            } else {
                if ($requests[$i]['is_secure']) {
                    $ssl_ms = $rtt;
                }
                break;
            }
        }
        // RTT's: DNS + Socket Connect + HTTP Request + 100ms allowance
        $target = $rtt * 3 + $ssl_ms + 100;
    }
    return $target;
}
开发者ID:emilstahl,项目名称:webpagetest,代码行数:52,代码来源:optimization_detail.inc.php

示例11: foreach

}
// fill in the actual thumbnails
$top = $thumbTop;
$thumb = null;
foreach ($tests as &$test) {
    $left = $thumbLeft;
    $top += $rowMargin;
    $testEnd = ceil($test['video']['end'] / $interval) * $interval;
    $lastThumb = null;
    if ($thumb) {
        imagedestroy($thumb);
        unset($thumb);
    }
    $frameCount = 0;
    $ms = 0;
    $localPaths = new TestPaths(GetTestPath($test['id']), $test['run'], $test['cached'], $test['step']);
    $videoDir = $localPaths->videoDir();
    while ($ms < $filmstrip_end_time) {
        $ms = $frameCount * $interval;
        $frameCount++;
        // find the closest video frame <= the target time
        $frame_ms = null;
        foreach ($test['video']['frames'] as $frameTime => $file) {
            if ($frameTime <= $ms && (!isset($frame_ms) || $frameTime > $frame_ms)) {
                $frame_ms = $frameTime;
            }
        }
        $path = null;
        if (isset($frame_ms)) {
            $path = $test['video']['frames'][$frame_ms];
        }
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:31,代码来源:filmstrip.php

示例12: header

header('Content-type: text/plain');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
set_time_limit(300);
include '../common.inc';
$location = $_REQUEST['location'];
$key = $_REQUEST['key'];
$id = $_REQUEST['id'];
logMsg("\n\nImage received for test: {$id}, location: {$location}, key: {$key}\n");
// load all of the locations
$locations = parse_ini_file('../settings/locations.ini', true);
$locKey = $locations[$location]['key'];
if (!strlen($locKey) || !strcmp($key, $locKey) || !strcmp($_SERVER['REMOTE_ADDR'], "127.0.0.1")) {
    if (isset($_FILES['file'])) {
        $fileName = $_FILES['file']['name'];
        $path = '../' . GetTestPath($id);
        // put each run of video data in it's own directory
        if (strpos($fileName, 'progress')) {
            $parts = explode('_', $fileName);
            if (count($parts)) {
                $runNum = $parts[0];
                $fileBase = $parts[count($parts) - 1];
                $cached = '';
                if (strpos($fileName, '_Cached')) {
                    $cached = '_cached';
                }
                $path .= "/video_{$runNum}{$cached}";
                if (!is_dir($path)) {
                    mkdir($path);
                }
                $fileName = 'frame_' . $fileBase;
开发者ID:kondrats,项目名称:Pagetest,代码行数:31,代码来源:resultimage.php

示例13: unset

     }
 }
 $path = null;
 if (isset($frame_ms)) {
     $path = $test['video']['frames'][$frame_ms];
 }
 if (!$lastThumb) {
     $lastThumb = $path;
 }
 if ($ms <= $testEnd) {
     unset($border);
     $cached = '';
     if ($test['cached']) {
         $cached = '_cached';
     }
     $imgPath = GetTestPath($test['id']) . "/video_{$test['run']}{$cached}/{$path}";
     if ($lastThumb != $path || !$thumb) {
         if ($lastThumb != $path) {
             $border = $colChanged;
         }
         // load the new thumbnail
         if ($thumb) {
             imagedestroy($thumb);
             unset($thuumb);
         }
         $tmp = imagecreatefromjpeg("./{$imgPath}");
         if ($tmp) {
             $thumb = imagecreatetruecolor($test['video']['thumbWidth'], $test['video']['thumbHeight']);
             fastimagecopyresampled($thumb, $tmp, 0, 0, 0, 0, $test['video']['thumbWidth'], $test['video']['thumbHeight'], imagesx($tmp), imagesy($tmp), 4);
             imagedestroy($tmp);
         }
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:filmstrip.php

示例14: GetTestResult

/**
* 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);
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $path = substr($testPath, 1);
    $pageData = loadAllPageData($testPath);
    $stats = array(0 => array(), 1 => array());
    $pageStats = calculatePageStats($pageData, $stats[0], $stats[1]);
    if (!strlen($url)) {
        $url = $pageData[1][0]['URL'];
    }
    $testInfo = GetTestInfo($id);
    if (is_file("{$testPath}/testinfo.ini")) {
        $test = parse_ini_file("{$testPath}/testinfo.ini", true);
    }
    $fvOnly = false;
    if (!count($stats[1])) {
        $fvOnly = true;
    }
    $cacheLabels = array('firstView', 'repeatView');
    // summary information
    $ret = array('id' => $id, 'url' => $url, 'summary' => "{$protocol}://{$host}{$uri}/results.php?test={$id}");
    $runs = max(array_keys($pageData));
    if (isset($testInfo)) {
        if (array_key_exists('url', $testInfo) && strlen($testInfo['url'])) {
            $ret['testUrl'] = $testInfo['url'];
        }
        if (array_key_exists('location', $testInfo) && strlen($testInfo['location'])) {
            $locstring = $testInfo['location'];
            if (array_key_exists('browser', $testInfo) && strlen($testInfo['browser'])) {
                $locstring .= ':' . $testInfo['browser'];
            }
            $ret['location'] = $locstring;
        }
        if (isset($test) && array_key_exists('test', $test) && is_array($test['test']) && array_key_exists('location', $test['test']) && strlen($test['test']['location'])) {
            $ret['from'] = $test['test']['location'];
        }
        if (array_key_exists('connectivity', $testInfo) && strlen($testInfo['connectivity'])) {
            $ret['connectivity'] = $testInfo['connectivity'];
        }
        if (array_key_exists('bwIn', $testInfo)) {
            $ret['bwDown'] = $testInfo['bwIn'];
        }
        if (array_key_exists('bwOut', $testInfo)) {
            $ret['bwUp'] = $testInfo['bwOut'];
        }
        if (array_key_exists('latency', $testInfo)) {
            $ret['latency'] = $testInfo['latency'];
        }
        if (array_key_exists('plr', $testInfo)) {
            $ret['plr'] = $testInfo['plr'];
        }
        if (array_key_exists('label', $testInfo) && strlen($testInfo['label'])) {
            $ret['label'] = $testInfo['label'];
        }
        if (array_key_exists('completed', $testInfo)) {
            $ret['completed'] = $testInfo['completed'];
        }
        if (array_key_exists('tester', $testInfo) && strlen($testInfo['tester'])) {
            $ret['tester'] = $testInfo['tester'];
        }
        if (array_key_exists('testerDNS', $testInfo) && strlen($testInfo['testerDNS'])) {
            $ret['testerDNS'] = $testInfo['testerDNS'];
        }
        if (array_key_exists('runs', $testInfo) && $testInfo['runs']) {
            $runs = $testInfo['runs'];
        }
        if (array_key_exists('fvonly', $testInfo)) {
            $fvOnly = $testInfo['fvonly'] ? true : false;
        }
    }
    $cachedMax = 0;
    if (!$fvOnly) {
        $cachedMax = 1;
    }
    $ret['runs'] = $runs;
    $ret['fvonly'] = $fvOnly;
    $ret['successfulFVRuns'] = CountSuccessfulTests($pageData, 0);
    if (!$fvOnly) {
        $ret['successfulRVRuns'] = CountSuccessfulTests($pageData, 1);
    }
    // average
    // check if removing average
    $addAverage = 1;
    if (isset($_GET['average'])) {
        if ($_GET['average'] == 0) {
            $addAverage = 0;
        }
    }
    // add average
    if ($addAverage == 1) {
//.........这里部分代码省略.........
开发者ID:JHand93,项目名称:WebPerformanceTestSuite,代码行数:101,代码来源:jsonResult.php

示例15: GetTestInfo

                     }
                     echo "\r\n";
                     $sentHeader = true;
                 }
                 $testInfo = GetTestInfo($path);
                 for ($i = 1; $i <= $test['test']['runs']; $i++) {
                     $additional = array($i, 0, SpeedIndex($path, $i, 0, $testInfo));
                     csvFile("{$path}/{$i}_{$fileType}", $label, $column_count, $additional);
                     $additional = array($i, 1, SpeedIndex($path, $i, 1, $testInfo));
                     csvFile("{$path}/{$i}_Cached_{$fileType}", $label, $column_count, $additional);
                 }
             } else {
                 csvPageData($testData['id'], $path, $test['test']['runs']);
             }
             foreach ($testData['v'] as $variationIndex => $variationId) {
                 $path = './' . GetTestPath($variationId);
                 $testInfo = GetTestInfo($path);
                 if ($hasCSV) {
                     for ($i = 1; $i <= $test['test']['runs']; $i++) {
                         $additional = array($i, 0, SpeedIndex($path, $i, 0, $testInfo));
                         csvFile("{$path}/{$i}_{$fileType}", "{$label} - {$tests['variations'][$variationIndex]['l']}", $column_count, $additional);
                         $additional = array($i, 1, SpeedIndex($path, $i, 1, $testInfo));
                         csvFile("{$path}/{$i}_Cached_{$fileType}", "{$label} - {$tests['variations'][$variationIndex]['l']}", $column_count, $additional);
                     }
                 } else {
                     csvPageData($variationId, $path, $test['test']['runs']);
                 }
             }
         }
     }
 } else {
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:31,代码来源:csv.php


注:本文中的GetTestPath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。