コード例 #1
0
ファイル: csv.php プロジェクト: lucasRolff/webpagetest
            if (!$is_requests) {
                echo ',"Speed Index"';
            }
            echo "\r\n";
            $testInfo = GetTestInfo($testPath);
            for ($i = 1; $i <= $test['test']['runs']; $i++) {
                $additional = array($i, 0);
                if (!$is_requests) {
                    $additional[] = SpeedIndex($testPath, $i, 0, $testInfo);
                }
                csvFile("{$testPath}/{$i}_{$fileType}", null, $column_count, $additional);
                $additional = array($i, 1);
                if (!$is_requests) {
                    $additional[] = SpeedIndex($testPath, $i, 1, $testInfo);
                }
                csvFile("{$testPath}/{$i}_Cached_{$fileType}", null, $column_count, $additional);
            }
        } else {
            csvPageData($id, $testPath, $test['test']['runs']);
        }
    }
    printResult();
} else {
    header("HTTP/1.0 404 Not Found");
}
function csvPageData($id, $testPath, $runs)
{
    if ($_GET['requests']) {
        for ($i = 1; $i <= $runs; $i++) {
            for ($cached = 0; $cached <= 1; $cached++) {
                $requests = getRequests($id, $testPath, $i, $cached, $secure, $loc, false);
コード例 #2
0
ファイル: csv.php プロジェクト: kondrats/Pagetest
header("Content-type: text/csv");
include 'common.inc';
$fileType = 'IEWPG.txt';
if ($_GET['requests']) {
    $fileType = 'IEWTR.txt';
}
// loop through all  of the results files (one per run) - both cached and uncached
$includeHeader = true;
for ($i = 1; $i <= $test['test']['runs']; $i++) {
    // build up the file name
    $fileName = "{$testPath}/{$i}_{$fileType}";
    csvFile($fileName, $includeHeader);
    $includeHeader = false;
    $fileName = "{$testPath}/{$i}_Cached_{$fileType}";
    csvFile($fileName, $includeHeader);
}
/**
* Take a tab-separated file, convert it to csv and spit it out
* 
* @param mixed $fileName
* @param mixed $includeHeader
*/
function csvFile($fileName, $includeHeader)
{
    $lines = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    if ($lines) {
        // loop through each line in the file
        foreach ($lines as $linenum => $line) {
            if ($linenum > 0 || $includeHeader) {
                $line = trim($line);