Example #1
0
/**
* Build the data set
*
* @param mixed $pageData
*/
function BuildHAR(&$pageData, $allRequests, $id, $testPath, $options)
{
    $result = array();
    $entries = array();
    $multistep = $options['multistep'] != 0;
    $result['log'] = array();
    $result['log']['version'] = '1.1';
    $result['log']['creator'] = array('name' => 'WebPagetest', 'version' => VER_WEBPAGETEST);
    $result['log']['pages'] = array();
    foreach ($pageData as $run => $pageRun) {
        foreach ($pageRun as $cached => $data) {
            $cached_text = '';
            if ($cached) {
                $cached_text = '_Cached';
            }
            $steps = array();
            if ($multistep) {
                foreach ($data as $stepName => $stepData) {
                    $steps[] = $stepData;
                }
            } else {
                $steps[] = $data;
            }
            if (!array_key_exists('browser', $result['log'])) {
                $result['log']['browser'] = array('name' => $steps[0]['browser_name'], 'version' => $steps[0]['browser_version']);
            }
            if (isset($allRequests)) {
                $requestsByStep = array();
                $runRequests = $allRequests[$run][$cached];
                if ($multistep) {
                    foreach ($runRequests as $stepName => $stepRequests) {
                        $requestsByStep[] = $stepRequests;
                    }
                } else {
                    $requestsByStep[] = $runRequests;
                }
            }
            if ($cached) {
                $cached_text = '_Cached';
            }
            for ($i = 0; $i < count($steps); $i++) {
                $stepData = $steps[$i];
                if (isset($requestsByStep)) {
                    $stepRequests = $requestsByStep[$i];
                }
                // add the page-level ldata to the result
                $pd = BuildHarPage($testPath, $cached, $run, $stepData);
                $result['log']['pages'][] = $pd;
                // now add the object-level data to the result
                $secure = false;
                $haveLocations = false;
                $stepName = isset($stepData['stepName']) ? $stepData['stepName'] : null;
                if (isset($stepRequests)) {
                    $requests = $stepRequests;
                    fixRequests($requests, $id, $testPath, $run, $cached, $secure, $haveLocations, false, true, null, $stepName);
                } else {
                    $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true, $stepName);
                }
                // add it to the list of entries
                foreach ($requests as $r) {
                    $entry = BuildHAREntry($stepData, $pd, $r);
                    $entries[] = $entry;
                }
                // add the bodies to the requests
                if (isset($options['bodies']) && $options['bodies']) {
                    $bodies_file = $testPath . '/' . $run . $cached_text . '_bodies.zip';
                    if (is_file($bodies_file)) {
                        $zip = new ZipArchive();
                        if ($zip->open($bodies_file) === TRUE) {
                            for ($i = 0; $i < $zip->numFiles; $i++) {
                                $index = intval($zip->getNameIndex($i), 10) - 1;
                                if (array_key_exists($index, $entries)) {
                                    $entries[$index]['response']['content']['text'] = utf8_encode($zip->getFromIndex($i));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $result['log']['entries'] = $entries;
    return $result;
}
Example #2
0
$page_data = loadPageRunData($testPath, $run, $cached, $requests);
$is_mime = (bool) @$_REQUEST['mime'];
$is_state = (bool) @$_REQUEST['state'];
$use_dots = !isset($_REQUEST['dots']) || $_REQUEST['dots'] != 0;
$show_labels = !isset($_REQUEST['labels']) || $_REQUEST['labels'] != 0;
$rowcount = array_key_exists('rowcount', $_REQUEST) ? $_REQUEST['rowcount'] : 0;
// Get all of the requests;
$is_secure = false;
$has_locations = false;
$use_location_check = false;
if (!isset($requests)) {
    $requests = getRequests($id, $testPath, $run, $cached, $is_secure, $has_locations, $use_location_check);
} else {
    // not multisteps enabled
    $requests = $requests[$run][$cached];
    fixRequests($requests, $id, $testPath, $run, $cached, $is_secure, $has_locations, $use_location_check);
}
if (@$_REQUEST['type'] == 'connection') {
    $is_state = true;
    $rows = GetConnectionRows($requests, $show_labels);
} else {
    $rows = GetRequestRows($requests, $use_dots, $show_labels);
}
$page_events = GetPageEvents($page_data);
$bwIn = 0;
if (isset($test) && array_key_exists('testinfo', $test) && array_key_exists('bwIn', $test['testinfo'])) {
    $bwIn = $test['testinfo']['bwIn'];
} else {
    if (isset($test) && array_key_exists('test', $test) && array_key_exists('bwIn', $test['test'])) {
        $bwIn = $test['test']['bwIn'];
    }
Example #3
0
            echo number_format($data['firstPaint'] / 1000.0, 3) . 's</td><td>';
        }
        echo number_format($data['domContentLoadedEventStart'] / 1000.0, 3) . 's - ' . number_format($data['domContentLoadedEventEnd'] / 1000.0, 3) . 's (' . number_format(($data['domContentLoadedEventEnd'] - $data['domContentLoadedEventStart']) / 1000.0, 3) . 's)' . '</td>';
        echo '<td>' . number_format($data['loadEventStart'] / 1000.0, 3) . 's - ' . number_format($data['loadEventEnd'] / 1000.0, 3) . 's (' . number_format(($data['loadEventEnd'] - $data['loadEventStart']) / 1000.0, 3) . 's)' . '</td>';
    }
    echo '</tr>';
    echo '</table><br>';
}
$secure = false;
$haveLocations = false;
if (!isset($requests)) {
    $requests = getRequests($id, $testPath, $run, @$_GET['cached'], $secure, $haveLocations, true, true);
} else {
    // not multisteps enabled
    $requests = $requests[$run][$cached];
    fixRequests($requests, $id, $testPath, $run, @$_GET['cached'], $secure, $haveLocations, true, true);
}
?>
                <script type="text/javascript">
                  markUserTime('aft.Detail Table');
                </script>

                <div style="text-align:center;">
                <h3 name="waterfall_view">Waterfall View</h3>
                <table border="1" bordercolor="silver" cellpadding="2px" cellspacing="0" style="width:auto; font-size:11px; margin-left:auto; margin-right:auto;">
                    <tr>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#1f7c83"></div></td><td>DNS Lookup</td></tr></table></td>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#e58226"></div></td><td>Initial Connection</td></tr></table></td>
                        <?php 
if ($secure) {
    ?>