. // tool for estimating FLOPS per job for a given app 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->elapsed_time * $result->flops_estimate; //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
samples: %d", $mean, $stdev, $count); } 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 version_select($appid) { $x = "\n"; return $x; } function analyze($appid, $app_version_id, $nresults) { global $hist; $clause = $app_version_id?" and app_version_id = $app_version_id ":""; $query = "select id, server_state, outcome, elapsed_time, flops_estimate from result where server_state=5 and appid=$appid and outcome=1 and validate_state=1 $clause order by id desc limit $nresults"; $r = mysql_query($query); $n = 0; while ($result = mysql_fetch_object($r)) { handle_result($result); $n++; } 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_app_select() { admin_page_head("Show FLOPS distribution"); echo "Select an application:
"; $apps = BoincApp::enum("deprecated=0"); foreach($apps as $app) { echo "
id> $app->user_friendly_name "; } echo "

"; admin_page_tail(); } function show_form($appid) { admin_page_head("Show FLOPS distribution"); echo " "; start_table(); row2("App version:", version_select($appid)); row2("Resolution:
(if you see only one bar, use a smaller value)", ""); row2("Sample size (# of jobs):", ""); row2("", ""); end_table(); echo "
"; admin_page_tail(); } if (get_str('submit', true)=='OK') { set_time_limit(0); $appid = get_int('appid'); $app_version_id = get_int('app_version_id'); $quantum = (double)(get_str('quantum')); $nresults = get_int('nresults'); analyze($appid, $app_version_id, $nresults); } else { $appid = get_int('appid', true); if ($appid) { show_form($appid); } else { show_app_select(); } } ?>