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


PHP getBreakdown函数代码示例

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


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

示例1: GetSingleRunData

/**
* Gather all of the data that we collect for a single run
* 
* @param mixed $id
* @param mixed $testPath
* @param mixed $run
* @param mixed $cached
*/
function GetSingleRunData($id, $testPath, $run, $cached, &$pageData, $testInfo)
{
    $ret = null;
    if (array_key_exists($run, $pageData) && is_array($pageData[$run]) && array_key_exists($cached, $pageData[$run]) && is_array($pageData[$run][$cached])) {
        $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);
        $ret = $pageData[$run][$cached];
        $ret['run'] = $run;
        $cachedText = '';
        if ($cached) {
            $cachedText = '_Cached';
        }
        if (isset($testInfo)) {
            if (array_key_exists('tester', $testInfo)) {
                $ret['tester'] = $testInfo['tester'];
            }
            if (array_key_exists('test_runs', $testInfo) && array_key_exists($run, $testInfo['test_runs']) && array_key_exists('tester', $testInfo['test_runs'][$run])) {
                $ret['tester'] = $testInfo['test_runs'][$run]['tester'];
            }
        }
        $basic_results = false;
        if (array_key_exists('basic', $_REQUEST) && $_REQUEST['basic']) {
            $basic_results = true;
        }
        if (!$basic_results && gz_is_file("{$testPath}/{$run}{$cachedText}_pagespeed.txt")) {
            $ret['PageSpeedScore'] = GetPageSpeedScore("{$testPath}/{$run}{$cachedText}_pagespeed.txt");
            $ret['PageSpeedData'] = "{$protocol}://{$host}{$uri}//getgzip.php?test={$id}&file={$run}{$cachedText}_pagespeed.txt";
        }
        $ret['pages'] = array();
        $ret['pages']['details'] = "{$protocol}://{$host}{$uri}/details.php?test={$id}&run={$run}&cached={$cached}";
        $ret['pages']['checklist'] = "{$protocol}://{$host}{$uri}/performance_optimization.php?test={$id}&run={$run}&cached={$cached}";
        $ret['pages']['breakdown'] = "{$protocol}://{$host}{$uri}/breakdown.php?test={$id}&run={$run}&cached={$cached}";
        $ret['pages']['domains'] = "{$protocol}://{$host}{$uri}/domains.php?test={$id}&run={$run}&cached={$cached}";
        $ret['pages']['screenShot'] = "{$protocol}://{$host}{$uri}/screen_shot.php?test={$id}&run={$run}&cached={$cached}";
        $ret['thumbnails'] = array();
        $ret['thumbnails']['waterfall'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_waterfall_thumb.png";
        $ret['thumbnails']['checklist'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_optimization_thumb.png";
        $ret['thumbnails']['screenShot'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_screen_thumb.png";
        $ret['images'] = array();
        $ret['images']['waterfall'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_waterfall.png";
        $ret['images']['connectionView'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_connection.png";
        $ret['images']['checklist'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_optimization.png";
        $ret['images']['screenShot'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_screen.jpg";
        if (is_file("{$testPath}/{$run}{$cachedText}_screen.png")) {
            $ret['images']['screenShotPng'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_screen.png";
        }
        $ret['rawData'] = array();
        $ret['rawData']['headers'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_report.txt";
        $ret['rawData']['pageData'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_IEWPG.txt";
        $ret['rawData']['requestsData'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_IEWTR.txt";
        $ret['rawData']['utilization'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_progress.csv";
        if (is_file("{$testPath}/{$run}{$cachedText}_bodies.zip")) {
            $ret['rawData']['bodies'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_bodies.zip";
        }
        if (!$basic_results) {
            $startOffset = array_key_exists('testStartOffset', $ret) ? intval(round($ret['testStartOffset'])) : 0;
            $progress = GetVisualProgress($testPath, $run, $cached, null, null, $startOffset);
            if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) {
                $cachedTextLower = strtolower($cachedText);
                $ret['videoFrames'] = array();
                foreach ($progress['frames'] as $ms => $frame) {
                    $videoFrame = array('time' => $ms);
                    $videoFrame['image'] = "http://{$host}{$uri}{$path}/video_{$run}{$cachedTextLower}/{$frame['file']}";
                    $videoFrame['VisuallyComplete'] = $frame['progress'];
                    $ret['videoFrames'][] = $videoFrame;
                }
            }
            $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true);
            $ret['domains'] = getDomainBreakdown($id, $testPath, $run, $cached, $requests);
            $ret['breakdown'] = getBreakdown($id, $testPath, $run, $cached, $requests);
            // check if removing requests
            $addRequests = 1;
            if (isset($_GET['requests'])) {
                if ($_GET['requests'] == 0) {
                    $addRequests = 0;
                }
            }
            // add requests
            if ($addRequests == 1) {
                $ret['requests'] = $requests;
            }
            $console_log = DevToolsGetConsoleLog($testPath, $run, $cached);
            if (isset($console_log)) {
                $ret['consoleLog'] = $console_log;
            }
            if (gz_is_file("{$testPath}/{$run}{$cachedText}_status.txt")) {
                $ret['status'] = array();
                $lines = gz_file("{$testPath}/{$run}{$cachedText}_status.txt");
                foreach ($lines as $line) {
                    $line = trim($line);
//.........这里部分代码省略.........
开发者ID:JHand93,项目名称:WebPerformanceTestSuite,代码行数:101,代码来源:jsonResult.php

示例2: CollectResults

/**
* Do any aggregation once all of the tests have finished
* 
* @param mixed $state
*/
function CollectResults(&$test, &$data)
{
    global $logFile;
    $testPath = './' . GetTestPath($test['id']);
    logMsg("Loading page data from {$testPath}", "./log/{$logFile}", true);
    $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;
                $test['has_data'] = 1;
            }
        }
    } 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;
    }
}
开发者ID:sethblanchard,项目名称:webpagetest,代码行数:49,代码来源:cron.php

示例3: array

     if (!array_key_exists('errors', $testInfo)) {
         $testInfo['errors'] = array();
     }
     if (!array_key_exists($runNumber, $testInfo['errors'])) {
         $testInfo['errors'][$runNumber] = array();
     }
     $testInfo['errors'][$runNumber][$cacheWarmed] = $_REQUEST['error'];
     $testInfo_dirty = true;
 }
 // Do any post-processing on this individual run that doesn't requre the test to be locked
 if (isset($runNumber) && isset($cacheWarmed)) {
     $secure = false;
     $haveLocations = false;
     $requests = getRequests($id, $testPath, $runNumber, $cacheWarmed, $secure, $haveLocations, false);
     if (isset($requests) && is_array($requests) && count($requests)) {
         getBreakdown($id, $testPath, $runNumber, $cacheWarmed, $requests);
     } else {
         $testerError = 'Missing Results';
     }
     if (is_dir('./google') && is_file('./google/google_lib.inc')) {
         require_once 'google/google_lib.inc';
         ParseCsiInfo($id, $testPath, $runNumber, $cacheWarmed, true);
     }
     GetDevToolsCPUTime($testPath, $runNumber, $cacheWarmed);
 }
 // mark this run as complete
 if (isset($runNumber) && isset($cacheWarmed)) {
     if ($testInfo['fvonly'] || $cacheWarmed) {
         if (!array_key_exists('test_runs', $testInfo)) {
             $testInfo['test_runs'] = array();
         }
开发者ID:krishnakanthpps,项目名称:webpagetest,代码行数:31,代码来源:workdone.php

示例4: DisplayGraphs

/**
* Display the comparison graph with the various time metrics
*
*/
function DisplayGraphs()
{
    global $tests;
    global $filmstrip_end_frame;
    require_once 'breakdown.inc';
    $mimeTypes = array('html', 'js', 'css', 'image', 'flash', 'font', 'other');
    $timeMetrics = array('visualComplete' => 'Visually Complete', 'lastVisualChange' => 'Last Visual Change', 'docTime' => 'Load Time (onload)', 'fullyLoaded' => 'Load Time (Fully Loaded)', 'domContentLoadedEventStart' => 'DOM Content Loaded', 'SpeedIndex' => 'Speed Index', 'TTFB' => 'Time to First Byte', 'titleTime' => 'Time to Title', 'render' => 'Time to Start Render', 'fullyLoadedCPUms' => 'CPU Busy Time');
    $progress_end = 0;
    $testCount = count($tests);
    foreach ($tests as &$test) {
        $requests;
        $test['breakdown'] = getBreakdown($test['id'], $test['path'], $test['run'], $test['cached'], $requests);
        if (array_key_exists('progress', $test['video']) && array_key_exists('frames', $test['video']['progress'])) {
            foreach ($test['video']['progress']['frames'] as $ms => &$data) {
                if ($ms > $progress_end && array_key_exists('progress', $data)) {
                    $progress_end = $ms;
                }
            }
        }
    }
    if ($progress_end) {
        if ($progress_end % 100) {
            $progress_end = intval((intval($progress_end / 100) + 1) * 100);
        }
        echo '<div id="compare_visual_progress" class="compare-graph"></div>';
    }
    if (count($tests) <= 4) {
        echo '<div id="compare_times" class="compare-graph"></div>';
        echo '<div id="compare_requests" class="compare-graph"></div>';
        echo '<div id="compare_bytes" class="compare-graph"></div>';
    } else {
        foreach ($timeMetrics as $metric => $label) {
            echo "<div id=\"compare_times_{$metric}\" class=\"compare-graph\"></div>";
        }
        foreach ($mimeTypes as $type) {
            echo "<div id=\"compare_requests_{$type}\" class=\"compare-graph\"></div>";
            echo "<div id=\"compare_bytes_{$type}\" class=\"compare-graph\"></div>";
        }
    }
    ?>
    <script type="text/javascript" src="<?php 
    echo $GLOBALS['ptotocol'];
    ?>
://www.google.com/jsapi"></script>
    <script type="text/javascript">
        google.load('visualization', '1', {'packages':['table', 'corechart']});
        google.setOnLoadCallback(drawCharts);
        function drawCharts() {
            var dataTimes = new google.visualization.DataTable();
            var dataRequests = new google.visualization.DataTable();
            var dataBytes = new google.visualization.DataTable();
            dataTimes.addColumn('string', 'Time (ms)');
            dataRequests.addColumn('string', 'MIME Type');
            dataBytes.addColumn('string', 'MIME Type');
            <?php 
    foreach ($tests as &$test) {
        $name = htmlspecialchars($test['name']);
        echo "dataTimes.addColumn('number', '{$name}');\n";
        echo "dataRequests.addColumn('number', '{$name}');\n";
        echo "dataBytes.addColumn('number', '{$name}');\n";
    }
    echo 'dataTimes.addRows(' . count($timeMetrics) . ");\n";
    echo 'dataRequests.addRows(' . strval(count($mimeTypes) + 1) . ");\n";
    echo 'dataBytes.addRows(' . strval(count($mimeTypes) + 1) . ");\n";
    if ($progress_end) {
        echo "var dataProgress = google.visualization.arrayToDataTable([\n";
        echo "  ['Time (ms)'";
        foreach ($tests as &$test) {
            echo ", '" . htmlspecialchars($test['name']) . "'";
        }
        echo " ]";
        for ($ms = 0; $ms <= $progress_end; $ms += 100) {
            echo ",\n  ['" . number_format($ms / 1000, 1) . "'";
            foreach ($tests as &$test) {
                $progress = 0;
                if (array_key_exists('last_progress', $test)) {
                    $progress = $test['last_progress'];
                }
                if (array_key_exists('progress', $test['video']) && array_key_exists('frames', $test['video']['progress']) && array_key_exists($ms, $test['video']['progress']['frames'])) {
                    $progress = $test['video']['progress']['frames'][$ms]['progress'];
                }
                $test['last_progress'] = $progress;
                if (array_key_exists('video', $test) && array_key_exists('progress', $test['video']) && array_key_exists('frames', $test['video']['progress'])) {
                    foreach ($test['video']['progress']['frames'] as $time => $frameInfo) {
                        if ($time <= $ms) {
                            $progress = floatval($frameInfo['progress']);
                        }
                    }
                }
                echo ", {$progress}";
            }
            echo "]";
        }
        echo "]);\n";
    }
    $row = 0;
//.........这里部分代码省略.........
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:101,代码来源:compare.php

示例5: xmlBreakdown

/**
* Dump a breakdown of the requests and bytes by mime type
*/
function xmlBreakdown($id, $testPath, $run, $cached)
{
    if (array_key_exists('breakdown', $_REQUEST) && $_REQUEST['breakdown']) {
        echo "<breakdown>\n";
        $requests;
        $breakdown = getBreakdown($id, $testPath, $run, $cached, $requests);
        foreach ($breakdown as $mime => &$values) {
            $domain = strrev($domain);
            echo "<{$mime}>\n";
            echo "<requests>{$values['requests']}</requests>\n";
            echo "<bytes>{$values['bytes']}</bytes>\n";
            echo "</{$mime}>\n";
        }
        echo "</breakdown>\n";
    }
}
开发者ID:sethblanchard,项目名称:webpagetest,代码行数:19,代码来源:xmlResult.php

示例6: array

require_once 'contentColors.inc';
require_once 'waterfall.inc';
require_once 'page_data.inc';
$page_keywords = array('Content Breakdown', 'MIME Types', 'Webpagetest', 'Website Speed Test', 'Page Speed');
$page_description = "Website content breakdown by mime type{$testLabel}";
$extension = 'php';
if (FRIENDLY_URLS) {
    $extension = 'png';
}
// walk through the requests and group them by mime type
$requestsFv;
$breakdownFv = getBreakdown($id, $testPath, $run, 0, $requestsFv);
$breakdownRv = array();
$requestsRv = array();
if ((int) $test[test][fvonly] == 0) {
    $breakdownRv = getBreakdown($id, $testPath, $run, 1, $requestsRv);
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>WebPagetest Content Breakdown<?php 
echo $testLabel;
?>
</title>
        <?php 
$gaTemplate = 'Content Breakdown';
include 'head.inc';
?>
        <style type="text/css">
            td {
开发者ID:Pankajchandan,项目名称:WPT-server,代码行数:31,代码来源:breakdown.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

示例8: htmlspecialchars

JpGraphError::SetErrLocale('prod');
// Get the various settings
$width = htmlspecialchars($_GET["width"]);
if (!$width) {
    $width = 500;
}
$height = htmlspecialchars($_GET["height"]);
if (!$height) {
    $height = 300;
}
$chartType = htmlspecialchars($_GET["type"]);
if (!strlen($chartType)) {
    $chartType = 'Requests';
}
// walk through the requests and group them by mime type
$breakdown = getBreakdown($id, $testPath, $run, $cached);
if (count($breakdown)) {
    // build up the data set
    $values = array();
    $index = 0;
    ksort($breakdown);
    foreach ($breakdown as $data) {
        if (!strcasecmp($chartType, 'Requests')) {
            $values[] = $data['requests'];
        } else {
            if (!strcasecmp($chartType, 'Bytes')) {
                $values[] = $data['bytes'];
            }
        }
        $index++;
    }
开发者ID:kondrat-shmoylov,项目名称:Pagetest,代码行数:31,代码来源:breakdownPie.php


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