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


PHP LockTest函数代码示例

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


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

/**
* Cancel and individual test
* 
* @param mixed $id
*/
function CancelTest($id)
{
    $lock = LockTest($id);
    if ($lock) {
        $cancelled = false;
        $testInfo = GetTestInfo($id);
        if ($testInfo && !array_key_exists('started', $testInfo)) {
            $testInfo['cancelled'] = time();
            SaveTestInfo($id, $testInfo);
            // delete the actual test file.
            if (array_key_exists('workdir', $testInfo)) {
                $ext = 'url';
                if ($testInfo['priority']) {
                    $ext = "p{$testInfo['priority']}";
                }
                $queued_job_file = $testInfo['workdir'] . "/{$id}.{$ext}";
                $cancelled = unlink($queued_job_file);
            }
        }
        UnlockTest($lock);
    }
    return $cancelled;
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:28,代码来源:cancelTest.php

示例3: GetTestInfo

     $testInfo = GetTestInfo($id);
     UnlockTest($testLock);
 }
 if ($testInfo && array_key_exists('location', $testInfo)) {
     $location = $testInfo['location'];
     $locKey = GetLocationKey($location);
     if (!strlen($locKey) || !strcmp($key, $locKey) || !strcmp($_SERVER['REMOTE_ADDR'], "127.0.0.1")) {
         $testErrorStr = '';
         if (array_key_exists('testerror', $_REQUEST) && strlen($_REQUEST['testerror'])) {
             $testErrorStr = ', Test Error: "' . $_REQUEST['testerror'] . '"';
         }
         if (array_key_exists('error', $_REQUEST) && strlen($_REQUEST['error'])) {
             $errorStr = ', Test Run Error: "' . $_REQUEST['error'] . '"';
         }
         logTestMsg($id, "Test Run Complete. Run: {$runNumber}, Cached: {$cacheWarmed}, Done: {$done}, Tester: {$tester}{$testErrorStr}{$errorStr}");
         $testLock = LockTest($id);
         $testInfo = GetTestInfo($id);
         // update the location time
         if (strlen($location)) {
             if (!is_dir('./tmp')) {
                 mkdir('./tmp', 0777, true);
             }
             touch("./tmp/{$location}.tm");
         }
         // Figure out the path to the results.
         $ini = parse_ini_file("{$testPath}/testinfo.ini");
         $time = time();
         $testInfo['last_updated'] = $time;
         // Allow for the test agents to indicate that they are including a
         // trace-based timeline (mostly for the mobile agents that always include it)
         if (isset($_REQUEST['timeline']) && $_REQUEST['timeline']) {
开发者ID:krishnakanthpps,项目名称:webpagetest,代码行数:31,代码来源:workdone.php

示例4: GetJob

/**
* Get an actual task to complete
* 
*/
function GetJob()
{
    $is_done = false;
    global $location;
    global $key;
    global $pc;
    global $ec2;
    global $tester;
    global $recover;
    global $is_json;
    global $dnsServers;
    $workDir = "./work/jobs/{$location}";
    $locKey = GetLocationKey($location);
    if (strpos($location, '..') == false && strpos($location, '\\') == false && strpos($location, '/') == false && (!strlen($locKey) || !strcmp($key, $locKey))) {
        if ($lock = LockLocation($location)) {
            $now = time();
            $testers = GetTesters($location, true);
            // make sure the tester isn't marked as offline (usually when shutting down EC2 instances)
            $testerCount = isset($testers['testers']) ? count($testers['testers']) : 0;
            $testerIndex = null;
            $offline = false;
            if ($testerCount) {
                if (strlen($ec2)) {
                    foreach ($testers['testers'] as $index => $testerInfo) {
                        if (isset($testerInfo['ec2']) && $testerInfo['ec2'] == $ec2 && isset($testerInfo['offline']) && $testerInfo['offline']) {
                            $offline = true;
                        }
                        break;
                    }
                }
                foreach ($testers['testers'] as $index => $testerInfo) {
                    if ($testerInfo['id'] == $tester) {
                        $testerIndex = $index;
                        break;
                    }
                }
            }
            if (!$offline) {
                $fileName = GetJobFile($workDir, $priority, $pc, $testerIndex, $testerCount);
                if (isset($fileName) && strlen($fileName)) {
                    $is_done = true;
                    $delete = true;
                    if ($is_json) {
                        header("Content-type: application/json");
                    } else {
                        header('Content-type: text/plain');
                    }
                    header("Cache-Control: no-cache, must-revalidate");
                    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
                    // send the test info to the test agent
                    $testInfo = file_get_contents("{$workDir}/{$fileName}");
                    // extract the test ID from the job file
                    if (preg_match('/Test ID=([^\\r\\n]+)\\r/i', $testInfo, $matches)) {
                        $testId = trim($matches[1]);
                    }
                    if (isset($testId)) {
                        // figure out the path to the results
                        $testPath = './' . GetTestPath($testId);
                        // flag the test with the start time
                        $ini = file_get_contents("{$testPath}/testinfo.ini");
                        if (stripos($ini, 'startTime=') === false) {
                            $time = time();
                            $start = "[test]\r\nstartTime=" . gmdate("m/d/y G:i:s", $time);
                            $out = str_replace('[test]', $start, $ini);
                            file_put_contents("{$testPath}/testinfo.ini", $out);
                        }
                        $lock = LockTest($testId);
                        if ($lock) {
                            $testInfoJson = GetTestInfo($testId);
                            if ($testInfoJson) {
                                if (!array_key_exists('tester', $testInfoJson) || !strlen($testInfoJson['tester'])) {
                                    $testInfoJson['tester'] = $tester;
                                }
                                if (isset($dnsServers) && strlen($dnsServers)) {
                                    $testInfoJson['testerDNS'] = $dnsServers;
                                }
                                if (!array_key_exists('started', $testInfoJson) || !$testInfoJson['started']) {
                                    $testInfoJson['started'] = $time;
                                    logTestMsg($testId, "Starting test (initiated by tester {$tester})");
                                }
                                if (!array_key_exists('test_runs', $testInfoJson)) {
                                    $testInfoJson['test_runs'] = array();
                                }
                                for ($run = 1; $run <= $testInfoJson['runs']; $run++) {
                                    if (!array_key_exists($run, $testInfoJson['test_runs'])) {
                                        $testInfoJson['test_runs'][$run] = array('done' => false);
                                    }
                                }
                                $testInfoJson['id'] = $testId;
                                ProcessTestShard($testInfoJson, $testInfo, $delete);
                                SaveTestInfo($testId, $testInfoJson);
                            }
                            UnlockTest($lock);
                        }
                        file_put_contents("./tmp/last-test-{$location}-{$tester}.test", $testId);
                    }
//.........这里部分代码省略.........
开发者ID:nowol79,项目名称:webpagetest-1,代码行数:101,代码来源:getwork.php

示例5: ShardKey

 $id = $today->format('ymd_') . ShardKey(rand()) . md5(uniqid(rand(), true));
 $path = './' . GetTestPath($id);
 // create the folder for the test results
 if (!is_dir($path)) {
     mkdir($path, 0777, true);
 }
 // extract the zip file
 $archive = new PclZip($_FILES['file']['tmp_name']);
 $list = $archive->extract(PCLZIP_OPT_PATH, "{$path}/");
 if (!$list) {
     unset($id);
 }
 // make sure there are no risky files and that nothing is allowed execute permission
 SecureDir($path);
 // mark the test as piblished so we won't expose a resubmit
 $lock = LockTest($id);
 if ($lock) {
     $testInfo = GetTestInfo($id);
     if ($testInfo) {
         $testInfo['id'] = $id;
         $testInfo['job'] = $id;
         $testInfo['published'] = true;
         if (array_key_exists('noscript', $_REQUEST) && $_REQUEST['noscript']) {
             $testInfo['script'] = null;
         }
         SaveTestInfo($id, $testInfo);
     }
     UnlockTest($lock);
 }
 if (is_file("{$path}/testinfo.ini")) {
     $ini = file("{$path}/testinfo.ini");
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:dopublish.php

示例6: GetJob


//.........这里部分代码省略.........
                // send the test info to the test agent
                $newline = strpos($testInfo, "\n", 2);
                if ($newline) {
                    $newline++;
                    $after = substr($testInfo, $newline);
                    $testInfo = substr($testInfo, 0, $newline);
                    $software = GetSetting('software');
                    if ($software) {
                        $testInfo .= "software={$software}\r\n";
                    }
                    if (GetSetting('enable_agent_processing')) {
                        $testInfo .= "processResults=1\r\n";
                    }
                    if (!$incremental) {
                        $testInfo .= "incremental=0\r\n";
                    }
                    $testInfo .= $after;
                }
                // extract the test ID from the job file
                if (preg_match('/Test ID=([^\\r\\n]+)\\r/i', $testInfo, $matches)) {
                    $testId = trim($matches[1]);
                }
                if (isset($testId)) {
                    // figure out the path to the results
                    $testPath = './' . GetTestPath($testId);
                    // flag the test with the start time
                    $ini = file_get_contents("{$testPath}/testinfo.ini");
                    if (stripos($ini, 'startTime=') === false) {
                        $time = time();
                        $start = "[test]\r\nstartTime=" . gmdate("m/d/y G:i:s", $time);
                        $out = str_replace('[test]', $start, $ini);
                        file_put_contents("{$testPath}/testinfo.ini", $out);
                    }
                    $lock = LockTest($testId);
                    if ($lock) {
                        $testInfoJson = GetTestInfo($testId);
                        if ($testInfoJson) {
                            if (!array_key_exists('tester', $testInfoJson) || !strlen($testInfoJson['tester'])) {
                                $testInfoJson['tester'] = $tester;
                            }
                            if (isset($dnsServers) && strlen($dnsServers)) {
                                $testInfoJson['testerDNS'] = $dnsServers;
                            }
                            if (!array_key_exists('started', $testInfoJson) || !$testInfoJson['started']) {
                                $testInfoJson['started'] = $time;
                                logTestMsg($testId, "Starting test (initiated by tester {$tester})");
                            }
                            if (!array_key_exists('test_runs', $testInfoJson)) {
                                $testInfoJson['test_runs'] = array();
                            }
                            for ($run = 1; $run <= $testInfoJson['runs']; $run++) {
                                if (!array_key_exists($run, $testInfoJson['test_runs'])) {
                                    $testInfoJson['test_runs'][$run] = array('done' => false);
                                }
                            }
                            $dotPos = stripos($testId, ".");
                            $testInfoJson['id'] = $dotPos === false ? $testId : substr($testId, $dotPos + 1);
                            ProcessTestShard($testInfoJson, $testInfo, $delete, $priority);
                            SaveTestInfo($testId, $testInfoJson);
                        }
                        UnlockTest($lock);
                    }
                }
                if ($delete) {
                    if (isset($fileName) && is_file("{$workDir}/{$fileName}")) {
                        unlink("{$workDir}/{$fileName}");
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:67,代码来源:getwork.php

示例7: CollectTestResult

function CollectTestResult($test, &$data)
{
    global $benchmark;
    $id = $test['id'];
    $count = 0;
    echo "Reprocessing Test {$id}...";
    logMsg("Reprocessing Test {$id}", "./log/reprocess-{$benchmark}.log", true);
    RestoreTest($id);
    ReprocessVideo($id);
    $testPath = './' . GetTestPath($id);
    $page_data = loadAllPageData($testPath);
    if (count($page_data)) {
        foreach ($page_data as $run => &$page_run) {
            foreach ($page_run as $cached => &$test_data) {
                $data_row = $test_data;
                unset($data_row['URL']);
                // figure out the per-type request info (todo: measure how expensive this is and see if we have a better way)
                $breakdown = getBreakdown($test['id'], $testPath, $run, $cached, $requests);
                foreach ($breakdown as $mime => &$values) {
                    $data_row["{$mime}_requests"] = $values['requests'];
                    $data_row["{$mime}_bytes"] = $values['bytes'];
                }
                // capture the page speed score
                if ($cached) {
                    $data_row['page_speed'] = GetPageSpeedScore("{$testPath}/{$run}_Cached_pagespeed.txt");
                } else {
                    $data_row['page_speed'] = GetPageSpeedScore("{$testPath}/{$run}_pagespeed.txt");
                }
                $data_row['url'] = $test['url'];
                $data_row['label'] = $test['label'];
                $data_row['location'] = $test['location'];
                $data_row['config'] = $test['config'];
                $data_row['cached'] = $cached;
                $data_row['run'] = $run;
                $data_row['id'] = $test['id'];
                $data[] = $data_row;
                $count++;
            }
        }
    } else {
        $data_row = array();
        $data_row['url'] = $test['url'];
        $data_row['label'] = $test['label'];
        $data_row['location'] = $test['location'];
        $data_row['config'] = $test['config'];
        $data_row['id'] = $test['id'];
        $data[] = $data_row;
    }
    // If the test was already archived, re-archive it.
    $testInfo = GetTestInfo($id);
    if (array_key_exists('archived', $testInfo) && $testInfo['archived']) {
        $lock = LockTest($id);
        if (isset($lock)) {
            $testInfo = GetTestInfo($id);
            $testInfo['archived'] = false;
            SaveTestInfo($id, $testInfo);
            UnlockTest($lock);
        }
        ArchiveTest($id);
    }
    echo "{$count} results\n";
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:62,代码来源:reprocess.php


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