function TimeSizeShapes($FileName, $Tests, $Langs, $Incl, $Excl, $HasHeading = TRUE) { list($data, $time_mins, $gz_mins) = ValidRowsAndMins($FileName, $Tests, $Langs, $Incl, $Excl, $HasHeading); $shapes = array(); $medians = array(); foreach ($data as $k => $test) { if (sizeof($test) / sizeof($Tests) > 0.5) { $points = array(); $xs = array(); $ys = array(); unset($minpoint); foreach ($test as $t => $v) { // wait until now to filter so sizeof($test) is consistent with FullWeightedData if ($Tests[$t][TEST_WEIGHT] > 0) { // normalized source code size on X, normalized measured time on Y $x = $v[DATA_GZ] / $gz_mins[$t]; $y = $v[DATA_TIME] / $time_mins[$t]; $points[] = array($x, $y); $xs[] = $x; // collect for median $ys[] = $y; // collect for median } } $shapes[$k] = $points; sort($xs); $xm = Median($xs); sort($ys); $ym = Median($ys); $medians[$k] = array($xm, $ym); // median } } return array($shapes, $medians); }
function FullWeightedData($FileName, $Tests, $Langs, $Incl, $Excl, $W, $SLangs, $HasHeading = TRUE) { list($data, $mins) = ValidRowsAndMins($FileName, $Tests, $Langs, $Incl, $Excl, $HasHeading); /* When there are multiple N values this doesn't seem quite right - we might have taken times from different programs for different N values for the same language implementation - but it's completely negligible. */ $weightedTestsCount = 0; foreach ($W as $k => $v) { if ($v > 0) { $weightedTestsCount++; } } $score = array(); foreach ($data as $k => $test) { if ($weightedTestsCount > 0 && sizeof($test) / $weightedTestsCount > 0.4) { $s = 0.0; $ws = 0.0; $include = 0.0; foreach ($test as $t => $testvalues) { foreach ($testvalues as $tv => $v) { $w1 = $W[$t] * $W['xfullcpu']; $w2 = $W[$t] * $W['xmem']; $w3 = $W[$t] * $W['xloc']; if ($w1 > 0) { $val = $v[DATA_TIME]; if ($val > 0) { $s += log($val / $mins[$t][$tv][CPU_MIN]) * $w1; $ws += $w1; $include += $val; } } if ($w2 > 0) { $val = $v[DATA_MEMORY]; if ($val > 0) { $s += log($val / $mins[$t][$tv][MEM_MIN]) * $w2; $ws += $w2; $include += $val; } } if ($w3 > 0) { $val = $v[DATA_GZ]; if ($val > 0) { $s += log($val / $mins[$t][$tv][GZ_MIN]) * $w3; $ws += $w3; $include += $val; } } } } if ($ws == 0.0) { $ws = 1.0; } if ($include > 0) { $score[$k] = array(1.0, exp($s / $ws), $weightedTestsCount - sizeof($test)); } } } uasort($score, 'CompareMeanScore'); $labels = array(); $ratio = array(); $allowed = array(); $count = 0; $max = 15; foreach ($score as $k => $v) { $r = $v[SCORE_MEAN]; $score[$k][SCORE_RATIO] = $r; if (isset($SLangs[$k])) { $labels[] = $k; $ratio[] = $r; $allowed[$k] = 1; $count++; } if ($count == $max) { break; } } return array($score, $labels, $ratio, $allowed); }