. error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); require_once("../inc/db.inc"); require_once("../inc/util_ops.inc"); db_init(); $hist = array(); $quantum = 1e10; $mean = 0; $count = 0; $varsum = 0; function handle_result($result) { global $hist; global $quantum; global $mean; global $count; global $varsum; $flops = $result->cpu_time * $result->p_fpops; //printf("%e
\n", $flops); $n = (int) ($flops/$quantum); if (!array_key_exists($n, $hist)) { $hist[$n] = 0; } $hist[$n]++; $count++; $delta = $flops - $mean; $mean += $delta/$count; $varsum += $delta*($flops-$mean); } function show_stats() { global $mean; global $count; global $varsum; global $sum; $stdev = sqrt($varsum/($count-1)); printf("mean: %e
stdev: %e", $mean, $stdev); } function show_stats_hist() { //deprecated global $hist; global $quantum; $sum = 0; $n = 0; foreach ($hist as $i=>$v) { $sum += $quantum*$i*$v; $n += $v; } $mean = $sum/$n; echo "mean: "; printf("%e", $mean); $sum = 0; foreach ($hist as $i=>$v) { $d = ($mean - $quantum*$i); $sum += $d*$d*$v; } $stdev = sqrt($sum/$n); echo "
stdev: "; printf("%e", $stdev); } function show_as_xml() { global $hist; global $quantum; echo "
";
    foreach ($hist as $i=>$v) {
        echo "<bin>
    <value>";
        printf("%e", $quantum*$i);
        echo "</value>
    <count>$v</count>
</bin>
";
    }
    echo "
"; } function show_as_table() { global $quantum; global $hist; echo ""; $keys = array_keys($hist); $start = reset($keys); $end = end($keys); $max = $hist[$start]; foreach ($hist as $v) { if ($v > $max) $max = $v; } for ($i=$start; $i<=$end; $i++) { if (array_key_exists($i, $hist)) { $w = 600*$hist[$i]/$max; } else { $w = 0; } $f = $i*$quantum; echo "\n"; } echo "
"; printf("%e ", $f); echo "
"; } function show_apps() { echo "

Apps:"; $r = mysql_query("select * from app"); while ($p = mysql_fetch_object($r)) { echo "
$p->id $p->user_friendly_name\n"; } } function show_platforms() { echo "

Platforms:
0 All
1 Windows only
2 Darwin only
3 Linux only "; } function analyze($appid, $platformid, $nresults) { global $hist; $clause = ""; switch ($platformid) { case 0: $clause = ""; break; case 1: $clause = " and locate('Windows', os_name)"; break; case 2: $clause = " and locate('Darwin', os_name)"; break; case 3: $clause = " and locate('Linux', os_name)"; break; } $query = "select server_state, outcome, cpu_time, p_fpops from result, host where server_state=5 and appid=$appid and host.id = result.hostid $clause limit $nresults"; $r = mysql_query($query); $n = 0; while ($result = mysql_fetch_object($r)) { switch ($result->outcome) { case 1: // success handle_result($result); $n++; break; case 2: // couldn't send case 3: // client error case 4: // no reply case 5: // didn't need case 6: // validate error case 7: // client detached } } if (!$n) { echo "No done results for that app"; exit; } ksort($hist); show_stats($hist); echo "


\n"; show_as_table(); echo "
\n"; show_as_xml(); } function show_form() { echo "
App ID:
platform ID (0 for all):
FLOP quantum:
# of results:
"; show_platforms(); show_apps(); } if ($_GET['submit']=='OK') { set_time_limit(0); $appid = $_GET['appid']; if (!$appid) { echo "Must supply an appid"; exit; } $platformid = $_GET['platformid']; $quantum = $_GET['quantum']; $nresults = $_GET['nresults']; analyze($appid, $platformid, $nresults); } else { show_form(); } ?>