Ejemplo n.º 1
0
function ProgramData($FileName, $T, $L, $I, $Langs, $Incl, $Excl)
{
    $rows = array();
    // $T and $L have already been checked
    $prefix = substr($T, 1) . ',' . $L . ',';
    $lines = file($FileName);
    foreach ($lines as $line) {
        if (strpos($line, $prefix)) {
            $row = explode(',', $line);
            $key = $T . $L . $row[DATA_ID];
            settype($row[DATA_ID], 'integer');
            if ($row[DATA_ID] == $I || $I == -1 && !isset($Excl[$key])) {
                settype($row[DATA_TESTVALUE], 'integer');
                settype($row[DATA_GZ], 'integer');
                settype($row[DATA_FULLCPU], 'double');
                settype($row[DATA_MEMORY], 'integer');
                settype($row[DATA_STATUS], 'integer');
                settype($row[DATA_ELAPSED], 'double');
                $rows[] = $row;
            }
        }
    }
    if ($I == -1) {
        $rows = BestRows($rows);
    }
    return $rows;
}
Ejemplo n.º 2
0
function HeadToHeadData($FileName, $Tests, $Langs, $Incl, $Excl, $L1, $L2, $HasHeading = TRUE)
{
    $measurements = array();
    $lines = file($FileName);
    $prefixL1 = ',' . $L1 . ',';
    $prefixL2 = ',' . $L2 . ',';
    $rowsL1 = array();
    $rowsL2 = array();
    foreach ($lines as $line) {
        $isLang1 = strpos($line, $prefixL1);
        if ($isLang1 || strpos($line, $prefixL2)) {
            $row = explode(',', $line);
            $test = $row[DATA_TEST];
            // do we need to check $test here?
            //         if (isset($Incl[$test])){
            if (isset($previous) && $previous != $test) {
                // assume ndata.csv is sorted by test
                AccumulateComparableRows(BestRows($rowsL1), BestRows($rowsL2), $measurements);
                $rowsL1 = array();
                $rowsL2 = array();
            }
            $previous = $test;
            $key = $test . $row[DATA_LANG] . $row[DATA_ID];
            settype($row[DATA_ID], 'integer');
            // $L1 and $L2 have already been checked
            if (!isset($Excl[$key])) {
                settype($row[DATA_STATUS], 'integer');
                settype($row[DATA_TESTVALUE], 'integer');
                settype($row[DATA_TIME], 'double');
                settype($row[DATA_GZ], 'double');
                settype($row[DATA_MEMORY], 'double');
                if ($isLang1) {
                    $rowsL1[] = $row;
                } else {
                    $rowsL2[] = $row;
                }
            }
            //         }
        }
    }
    AccumulateComparableRows(BestRows($rowsL1), BestRows($rowsL2), $measurements);
    // collect values for chart and stats
    $ratios = array();
    $times = array();
    $mismatches = array();
    foreach ($measurements as $v) {
        $test = $v[0][DATA_TEST];
        if ($test != NULL && $Tests[$test][TEST_WEIGHT] <= 0 || $v[DATA_TIME] == NO_VALUE) {
            continue;
        }
        $ratios[] = $v[DATA_TIME];
        // Too many confuse default memory use with program memory use
        if ($test == 'binarytrees' || $test == 'regexdna' || $test == 'revcomp' || $test == 'knucleotide') {
            $ratios[] = $v[DATA_MEMORY];
        } else {
            $ratios[] = 0.0;
        }
        $ratios[] = $v[DATA_GZ];
        $times[] = $v[DATA_TIME];
        $mismatches[$test] = isMulticore($v[0][DATA_LOAD]) != isMulticore($v[1][DATA_LOAD]);
    }
    // sort by x times faster
    uasort($measurements, 'CompareTimeRatio');
    $sorted = array();
    foreach ($measurements as $rows) {
        $test = isset($rows[0]) ? $rows[0][DATA_TEST] : $rows[1][DATA_TEST];
        $sorted[$test] = $rows;
    }
    foreach ($Tests as $k => $v) {
        if (!isset($sorted[$k])) {
            $sorted[$k] = array();
        }
    }
    $stats = Percentiles($times);
    return array($sorted, $ratios, $stats, $mismatches);
}