All checks were successful
Build and Deploy / build_and_deploy (push) Successful in 1m8s
1191 lines
38 KiB
PHP
1191 lines
38 KiB
PHP
<?php
|
|
// If you are seeing this message I fucked up big time at
|
|
// https://git.mixedup.dev/themixedupstuff/1000fps
|
|
//
|
|
// Tell me about it.
|
|
|
|
require_once __DIR__."/../vendor/autoload.php";
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] != "POST")
|
|
{
|
|
if (filter_var(getenv("DEBUG"), FILTER_VALIDATE_BOOLEAN))
|
|
{
|
|
$preview_mode = true;
|
|
}
|
|
else
|
|
{
|
|
http_response_code(405);
|
|
print ("HTTP method not allowed, must POST.");
|
|
header("Allow", "POST");
|
|
return;
|
|
}
|
|
}
|
|
|
|
# Verify, sanitize and convert form values.
|
|
$app_title = $_POST["app-title"];
|
|
$app_author = $_POST["app-author"];
|
|
$samples_file = $_FILES["samples"];
|
|
$client_w = $_POST["client-w"];
|
|
$client_h = $_POST["client-h"];
|
|
$penalty_stutters = $_POST["penalty-stutters"];
|
|
$penalty_audio = $_POST["penalty-audio"];
|
|
$hw_info = $_POST["hw-info"];
|
|
$caveats = $_POST["caveats"];
|
|
|
|
if ($preview_mode)
|
|
{
|
|
$app_title = "Lorem Ipsum";
|
|
$app_author = "Dolor Sit Amet";
|
|
$samples_file = "";
|
|
$client_w = 1920;
|
|
$client_h = 1080;
|
|
$penalty_stutters = false;
|
|
$penalty_audio = false;
|
|
$hw_info = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nunc est, suscipit at enim vitae, interdum consectetur metus. Vivamus tempor facilisis ex, ac facilisis tellus malesuada sit amet. Mauris sed dui sed felis sodales efficitur at ut ligula. Aenean sit amet augue accumsan, molestie augue et, iaculis magna. Nam a enim ut neque eleifend eleifend. Cras libero ex, viverra eu sollicitudin eu, sodales mollis purus. Praesent iaculis magna tincidunt mi pretium tincidunt. Donec posuere libero malesuada dui convallis euismod. Morbi commodo mi elit, ac egestas ante faucibus at. Aliquam non mi nec quam efficitur interdum lobortis at ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Curabitur nec feugiat quam, vitae imperdiet nibh. Fusce lobortis risus a lacus scelerisque cursus. Phasellus rutrum dolor blandit lectus ultrices pretium. Donec ullamcorper sapien metus, a viverra nisl imperdiet in. ";
|
|
$caveats = "Phasellus porta laoreet leo, condimentum porta ante ullamcorper eu. Mauris a aliquet enim. Integer volutpat maximus libero eget venenatis. Curabitur felis nisi, aliquet a ultrices in, scelerisque quis sem. Suspendisse potenti. Ut pulvinar non dolor quis consectetur. Maecenas eget ultrices purus, eget sagittis urna. Quisque condimentum in odio varius tincidunt. Mauris eget tellus id lacus scelerisque aliquet. Nulla sit amet porttitor tellus. Donec justo urna, elementum ut pellentesque eget, sollicitudin eu ligula. Mauris at imperdiet sem. ";
|
|
|
|
$form_ok = true;
|
|
}
|
|
else
|
|
{
|
|
$form_ok = verify_form_args();
|
|
}
|
|
|
|
function verify_form_args()
|
|
{
|
|
$form_ok = true;
|
|
|
|
if (!isset($app_title))
|
|
{
|
|
print "<p>app-title is required.</p>";
|
|
$form_ok = false;
|
|
}
|
|
else if (strlen($app_title) > 1024)
|
|
{
|
|
print "<p>app-title too long (< 1024).</p>";
|
|
|
|
# panic for strings too large
|
|
http_response_code(400);
|
|
die();
|
|
}
|
|
else
|
|
{
|
|
$app_title = htmlspecialchars($app_title);
|
|
}
|
|
|
|
if (isset($app_author))
|
|
{
|
|
if (strlen($app_author) > 1024)
|
|
{
|
|
print "<p>app-author too long (< 1024).</p>";
|
|
# panic for strings too large
|
|
http_response_code(400);
|
|
die();
|
|
}
|
|
else
|
|
{
|
|
$app_author = htmlspecialchars($app_author);
|
|
}
|
|
}
|
|
|
|
if (!isset($samples_file))
|
|
{
|
|
print "<p>samples are required.</p>";
|
|
$form_ok = false;
|
|
}
|
|
else
|
|
{
|
|
if (!isset($samples_file))
|
|
{
|
|
print "<p>samples file is missing from the form data.</p>";
|
|
$form_ok = false;
|
|
}
|
|
else
|
|
{
|
|
if ($samples_file["size"] > 10000000)
|
|
{
|
|
print "<p>Way too many samples, trim your collected data and resend.</p>";
|
|
$form_ok = false;
|
|
}
|
|
|
|
switch ($samples_file["type"])
|
|
{
|
|
case "application/octet-stream": # bit odd but okay
|
|
case "text/csv":
|
|
case "text/plain":
|
|
break;
|
|
default:
|
|
print "<p>Unknown or unsupported samples file type.</p>";
|
|
$form_ok = false;
|
|
break;
|
|
}
|
|
|
|
# try reading the samples file to see if it actually a csv file.
|
|
{
|
|
$file = fopen($samples_file["tmp_name"], "r");
|
|
$line = fgets($file);
|
|
$number = filter_var($line, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
|
|
|
if (!$number)
|
|
{
|
|
print "<p>First row and column in the samples file doesn't seem to be a number.</p>";
|
|
$form_ok = false;
|
|
}
|
|
|
|
fclose($file);
|
|
}
|
|
|
|
# Otherwise I assume everything is a-ok.
|
|
}
|
|
}
|
|
|
|
$client_w = filter_var($client_w, FILTER_VALIDATE_INT);
|
|
$client_h = filter_var($client_h, FILTER_VALIDATE_INT);
|
|
|
|
if ($client_w == false || $client_h == false || $client_w < 0 || $client_h < 0)
|
|
{
|
|
print "<p>Client area (client-w client-h) must be postiive integers.</p>";
|
|
$form_ok = false;
|
|
}
|
|
|
|
$penalty_stutters = filter_var($penalty_stutters, FILTER_VALIDATE_BOOLEAN);
|
|
$penalty_audio = filter_var($penalty_audio, FILTER_VALIDATE_BOOLEAN);
|
|
|
|
$pd = new Parsedown();
|
|
|
|
# TODO: markdown format hwinfo and caveats.
|
|
if (isset($hw_info) && strlen($hw_info) > 4096)
|
|
{
|
|
print "<p>Length of the hw-info string is too large. Keep it small.<p>";
|
|
# panic for strings too large
|
|
http_response_code(400);
|
|
die();
|
|
}
|
|
else
|
|
{
|
|
$hw_info = $pd->text($hw_info);
|
|
}
|
|
|
|
if (isset($caveats) && strlen($caveats) > 4096)
|
|
{
|
|
print "<p>Length of the caveats string is too large. Keep it small.<p>";
|
|
# panic for strings too large
|
|
http_response_code(400);
|
|
die();
|
|
}
|
|
else
|
|
{
|
|
$caveats = $pd->text($caveats);
|
|
}
|
|
|
|
return $form_ok;
|
|
}
|
|
|
|
function print_a($arr) {
|
|
print '<code><pre style="text-align:left; margin:10px;">'.print_r($arr, TRUE).'</pre></code>';
|
|
}
|
|
|
|
if (!$form_ok)
|
|
{
|
|
http_response_code(400);
|
|
|
|
print "<h3>Debug Data</h3>";
|
|
|
|
|
|
print_a($_POST);
|
|
print_a($_FILES);
|
|
return;
|
|
}
|
|
|
|
function read_all_samples($file) {
|
|
while (($line = fgets($file)) != false) {
|
|
yield (float)filter_var($line, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
|
}
|
|
}
|
|
|
|
function median($sorted_array) {
|
|
$len = count($sorted_array);
|
|
|
|
if ($len == 0)
|
|
{
|
|
die("How come you have zero samples in the file.");
|
|
return;
|
|
}
|
|
|
|
$pivot = (int)($len / 2);
|
|
if ($len % 2 == 0) {
|
|
$median = 0.5*($sorted_array[$pivot] + $sorted_array[$pivot+1]);
|
|
} else {
|
|
$median = $sorted_array[$pivot];
|
|
}
|
|
|
|
return $median;
|
|
}
|
|
|
|
function mean($array) {
|
|
$factor = 1/count($array);
|
|
|
|
$mean = 0;
|
|
foreach ($array as $x)
|
|
{
|
|
$mean += $factor * $x;
|
|
}
|
|
|
|
return $mean;
|
|
}
|
|
|
|
function std($array, $mean) {
|
|
$factor = 1/count($array);
|
|
|
|
$sigma2 = 0;
|
|
|
|
foreach ($array as $x)
|
|
{
|
|
$y = $x - $mean;
|
|
$y *= $y;
|
|
$sigma2 += $factor * $y;
|
|
}
|
|
|
|
return sqrt($sigma2);
|
|
}
|
|
|
|
function gradefunc($fps) {
|
|
$m = 1.0604;
|
|
$b = -3.3237;
|
|
return $m * log($fps) + $b;
|
|
}
|
|
|
|
function hist($sorted_array, $std) {
|
|
# Use Scott's rule for bin width.
|
|
$n = count($sorted_array);
|
|
$h = 3.49*$std/pow($n, 0.333);
|
|
|
|
$min = $sorted_array[0];
|
|
$max = $sorted_array[$n-1];
|
|
|
|
$k = (int)(($max-$min) / $h);
|
|
|
|
$hist = array();
|
|
|
|
// printf("%f<br>", $n);
|
|
// printf("%f<br>",$h);
|
|
// printf("%f<br>",$min); printf("%f<br>",$max);
|
|
// printf("%f<br>",$k);
|
|
|
|
for ($i = 0; $i < $k; $i++)
|
|
{
|
|
$head = $min + $i * $h;
|
|
$tail = $min + ($i + 1) * $h;
|
|
|
|
$y = count(array_filter($sorted_array, function ($x) use($head, $tail) {
|
|
return $x >= $head && $x < $tail;
|
|
}));
|
|
|
|
# [ sprintf("%.3f-%.3f", $head, $tail),
|
|
array_push($hist, [sprintf("%.3f-%.3f", $head, $tail), $y ]);
|
|
}
|
|
|
|
return $hist;
|
|
}
|
|
|
|
function grade2letter($g) {
|
|
if ($g >= 4)
|
|
return 'A';
|
|
else if ($g > 3)
|
|
return 'B';
|
|
else if ($g > 2)
|
|
return 'C';
|
|
else if ($g > 1)
|
|
return 'D';
|
|
else if ($g > -0.15)
|
|
return 'F';
|
|
else
|
|
return 'FF';
|
|
}
|
|
|
|
$penalty = 0;
|
|
|
|
if ($client_w < 1280 && $client_h < 720)
|
|
$penalty += 5;
|
|
else if ($client_w < 1920 && $client_h < 1080)
|
|
$penalty += 1;
|
|
|
|
if ($penalty_stutters) $penalty += 1;
|
|
if ($penalty_audio) $penalty += 1;
|
|
|
|
if ($preview_mode)
|
|
{
|
|
$mu = 0.0001;
|
|
$sigma = 0.00005;
|
|
|
|
$samples = array(
|
|
0.000925925925925926,
|
|
0.00104766893661603,
|
|
0.000911577028258888,
|
|
0.000945179584120983,
|
|
0.000908265213442325,
|
|
0.000930232558139535,
|
|
0.00111719360965255,
|
|
0.00113726828158763,
|
|
0.00102072062876391,
|
|
0.00103316458311809,
|
|
0.000973709834469328,
|
|
0.000980392156862745,
|
|
0.000877963125548727,
|
|
0.000930232558139535,
|
|
0.000909090909090909,
|
|
0.00110913930789707,
|
|
0.000958772770853308,
|
|
0.000963391136801541,
|
|
0.000971817298347911,
|
|
0.000907441016333938,
|
|
0.000936329588014981,
|
|
0.00101543460601137,
|
|
0.00111445447453472,
|
|
0.00118049817022784,
|
|
0.00115834588208039,
|
|
0.00121773015099854,
|
|
0.00116441546343735,
|
|
0.00155159038013964,
|
|
0.00137193030594046,
|
|
0.00133084908171413,
|
|
0.00131943528169943,
|
|
0.00135722041259501,
|
|
0.00111557340473003,
|
|
0.00153280196198651,
|
|
0.00141262890238734,
|
|
0.00116795141322121,
|
|
0.00136593361562628,
|
|
0.00122159784998778,
|
|
0.00122428991185113,
|
|
0.00114090131203651,
|
|
0.00128949065119278,
|
|
0.00158102766798419,
|
|
0.00102827763496144,
|
|
0.0010873110796999,
|
|
0.00111844312716698,
|
|
0.00137249519626681,
|
|
0.00124750499001996,
|
|
0.00139024051160851,
|
|
0.00132292631300437,
|
|
0.00111619600401831,
|
|
0.00110570544007077,
|
|
0.00115340253748558,
|
|
0.00110204981265153,
|
|
0.00107596298687325,
|
|
0.00105496360375567,
|
|
0.00136911281489595,
|
|
0.00150308131669923,
|
|
0.00132855055134848,
|
|
0.00109265734265734,
|
|
0.00115127791848952,
|
|
0.00117096018735363,
|
|
0.0011005943209333,
|
|
0.00136407038603192,
|
|
0.00114995400183993,
|
|
0.00113199003848766,
|
|
0.00129048909536714,
|
|
0.00144237703735757,
|
|
0.00128700128700129,
|
|
0.00113765642775882,
|
|
0.00119817876827223,
|
|
0.00137061403508772,
|
|
0.00132855055134848,
|
|
0.00121124031007752,
|
|
0.0013607293509321,
|
|
0.00150579731968077,
|
|
0.00130106687483737,
|
|
0.00130259215839521,
|
|
0.00117771758332352,
|
|
0.00113947128532361,
|
|
0.00127991808524254,
|
|
0.0012071463061323,
|
|
0.0011401208528104,
|
|
0.00132749236691889,
|
|
0.00131648235913639,
|
|
0.00163052339801076,
|
|
0.00132082948091401,
|
|
0.00127064803049555,
|
|
0.001354096140826,
|
|
0.0012779552715655,
|
|
0.00119889701474643,
|
|
0.00127502231289048,
|
|
0.00122594090964816,
|
|
0.00134535180949818,
|
|
0.00123992560446373,
|
|
0.00129567245400363,
|
|
0.00125423303649818,
|
|
0.00118581762124985,
|
|
0.00119545726240287,
|
|
0.00127420998980632,
|
|
0.00128899200824955,
|
|
0.001271132579128,
|
|
0.00127226463104326,
|
|
0.00135153399107988,
|
|
0.00142897970848814,
|
|
0.00141602945341263,
|
|
0.00151194436044754,
|
|
0.00141622999575131,
|
|
0.00137551581843191,
|
|
0.00141083521444695,
|
|
0.00121109361753664,
|
|
0.00121256214380987,
|
|
0.00135814206165965,
|
|
0.0013745704467354,
|
|
0.0016246953696182,
|
|
0.00142959256611866,
|
|
0.00182748538011696,
|
|
0.00152858453072455,
|
|
0.00132432790358893,
|
|
0.0013419216317767,
|
|
0.0014166312508854,
|
|
0.00139043381535039,
|
|
0.00127048659636641,
|
|
0.00128899200824955,
|
|
0.00131873928524331,
|
|
0.00124100273020601,
|
|
0.0012132977432662,
|
|
0.00112435349673938,
|
|
0.00127893592531014,
|
|
0.0012465719272002,
|
|
0.00111358574610245,
|
|
0.00115767538782126,
|
|
0.00120831319478009,
|
|
0.00152671755725191,
|
|
0.00139431121026213,
|
|
0.00125643925116221,
|
|
0.00146972369194591,
|
|
0.00167954316425932,
|
|
0.00114116170261326,
|
|
0.00122639195486878,
|
|
0.00121241513094083,
|
|
0.00122549019607843,
|
|
0.00128402670775552,
|
|
0.0012108003390241,
|
|
0.0011180679785331,
|
|
0.00131630906936949,
|
|
0.00115740740740741,
|
|
0.00118315191670611,
|
|
0.00122850122850123,
|
|
0.00138350857775318,
|
|
0.00137343771459964,
|
|
0.00115460108532502,
|
|
0.00140785583556244,
|
|
0.0012970168612192,
|
|
0.00125297581756672,
|
|
0.00139742873113471,
|
|
0.00128766417718259,
|
|
0.00120598166907863,
|
|
0.00116009280742459,
|
|
0.00115874855156431,
|
|
0.00120554550934298,
|
|
0.0013197835554969,
|
|
0.00131095962244363,
|
|
0.0011706860220089,
|
|
0.00119574315437044,
|
|
0.00144133756125685,
|
|
0.00147297098247165,
|
|
0.00123456790123457,
|
|
0.00141242937853107,
|
|
0.00123107226394189,
|
|
0.00161733786187935,
|
|
0.00157529930686831,
|
|
0.00116645281698355,
|
|
0.00140845070422535,
|
|
0.00142247510668563,
|
|
0.00130821559392988,
|
|
0.00139295166457724,
|
|
0.00137061403508772,
|
|
0.00126135216952573,
|
|
0.00117827265229174,
|
|
0.00131769666622743,
|
|
0.00117439812096301,
|
|
0.00134934556739981,
|
|
0.00142267747901551,
|
|
0.0014194464158978,
|
|
0.00156666144446185,
|
|
0.00126119308866187,
|
|
0.00120163422254266,
|
|
0.00111769308147983,
|
|
0.00119717466778403,
|
|
0.00117178345441762,
|
|
0.00123594116920035,
|
|
0.00126326427488631,
|
|
0.00124424536518602,
|
|
0.00145327713995059,
|
|
0.00120656370656371,
|
|
0.00112777715123492,
|
|
0.00102438024994878,
|
|
0.000991080277502478,
|
|
0.00122624156958921,
|
|
0.00102009588901357,
|
|
0.000877963125548727,
|
|
0.000870322019147084,
|
|
0.000870322019147084,
|
|
0.000909918107370337,
|
|
0.00101255569056298,
|
|
0.0010873110796999,
|
|
0.00088809946714032,
|
|
0.000965250965250965,
|
|
0.0010338054378166,
|
|
0.000878734622144112,
|
|
0.000901713255184851,
|
|
0.000967117988394584,
|
|
0.000894454382826476,
|
|
0.000886524822695035,
|
|
0.000894454382826476,
|
|
0.000831946755407654,
|
|
0.000849617672047579,
|
|
0.000866551126516464,
|
|
0.000914913083257091,
|
|
0.000858369098712446,
|
|
0.000915750915750916,
|
|
0.000936329588014981,
|
|
0.00100553041729512,
|
|
0.000959692898272553,
|
|
0.00094876660341556,
|
|
0.00110204981265153,
|
|
0.00114103149246919,
|
|
0.00127145581691036,
|
|
0.00112663361874718,
|
|
0.00101450745662981,
|
|
0.00118273211117682,
|
|
0.00118273211117682,
|
|
0.00122010736944851,
|
|
0.00115473441108545,
|
|
0.00117799505242078,
|
|
0.00118119536971415,
|
|
0.00118497452304776,
|
|
0.00128024580719498,
|
|
0.00168378514901499,
|
|
0.00129483361388062,
|
|
0.00131734949282045,
|
|
0.00131027253668763,
|
|
0.00115406809001731,
|
|
0.00119703136222169,
|
|
0.00122804863072578,
|
|
0.00113726828158763,
|
|
0.00112032265292404,
|
|
0.00108707468203066,
|
|
0.00157282164202579,
|
|
0.00135740464232388,
|
|
0.001220703125,
|
|
0.00128998968008256,
|
|
0.00114103149246919,
|
|
0.00110277900308778,
|
|
0.00105909764880322,
|
|
0.00114718366410462,
|
|
0.00103777501037775,
|
|
0.00100391526955125,
|
|
0.00117924528301887,
|
|
0.00115433452614568,
|
|
0.00112599932440041,
|
|
0.00114982177762447,
|
|
0.00125344697919278,
|
|
0.00290782204129107,
|
|
0.00119075970469159,
|
|
0.00125960448419196,
|
|
0.00104821802935011,
|
|
0.00107584722969338,
|
|
0.00119875329657157,
|
|
0.00119345984007638,
|
|
0.00117233294255569,
|
|
0.00112498593767578,
|
|
0.00111756817165847,
|
|
0.00121285627653123,
|
|
0.00114181319936059,
|
|
0.00124254473161034,
|
|
0.00123578843302027,
|
|
0.00137117784176608,
|
|
0.00161812297734628,
|
|
0.00166030217499585,
|
|
0.0015938795027096,
|
|
0.00139801481895708,
|
|
0.001478633742422,
|
|
0.00144446049400549,
|
|
0.00133049494411921,
|
|
0.00136332651670075,
|
|
0.00159134309357097,
|
|
0.00147080453007795,
|
|
0.00145496871817256,
|
|
0.00170096955264501,
|
|
0.00137438152831226,
|
|
0.0013317352510321,
|
|
0.0016366612111293,
|
|
0.00208681135225376,
|
|
0.00174978127734033,
|
|
0.00190439916206437,
|
|
0.00176304654442877,
|
|
0.00172205958326158,
|
|
0.00274951883420401,
|
|
0.0018470631695604,
|
|
0.00180310133429499,
|
|
0.00168976005407232,
|
|
0.00186462800671266,
|
|
0.00165453342157512,
|
|
0.00154631204577084,
|
|
0.00165700082850041,
|
|
0.00132065504490227,
|
|
0.0024390243902439,
|
|
0.00193274062620796,
|
|
0.0022670596236681,
|
|
0.00205676676264912,
|
|
0.00189071658158442,
|
|
0.00182882223847842,
|
|
0.00186741363211952,
|
|
0.00159948816378759,
|
|
0.00202470135654991,
|
|
0.00176928520877566,
|
|
0.0018896447467876,
|
|
0.00182882223847842,
|
|
0.00182215743440233,
|
|
0.00227842333105491,
|
|
0.00167252048837598,
|
|
0.00163505559189012,
|
|
0.00208507089241034,
|
|
0.00205380981721093,
|
|
0.00171144959780935,
|
|
0.00161603102779573,
|
|
0.00185082361650935,
|
|
0.00187687687687688,
|
|
0.00223264121455682,
|
|
0.00179018976011457,
|
|
0.00196850393700787,
|
|
0.00180212650928095,
|
|
0.00201572263656521,
|
|
0.00190876121397213,
|
|
0.00200240288346015,
|
|
0.00204666393778142,
|
|
0.00201491033649003,
|
|
0.00190912562046583,
|
|
0.00167000668002672,
|
|
0.00160771704180064,
|
|
0.00176740897843761,
|
|
0.00161290322580645,
|
|
0.00176897222713603,
|
|
0.00139997200055999,
|
|
0.00135685210312076,
|
|
0.00131682907558599,
|
|
0.0013271400132714,
|
|
0.00122458976242959,
|
|
0.00134661998384056,
|
|
0.00125015626953369,
|
|
0.00121832358674464,
|
|
0.00120627261761158,
|
|
0.00139062717285496,
|
|
0.00170212765957447,
|
|
0.00141422712487626,
|
|
0.00138178803371563,
|
|
0.00143843498273878,
|
|
0.00142897970848814,
|
|
0.00137438152831226,
|
|
0.00135722041259501,
|
|
0.00130616509926855,
|
|
0.00125423303649818,
|
|
0.00126710593005575,
|
|
0.00119104335397809,
|
|
0.00117164616285882,
|
|
0.00139217597104274,
|
|
0.00132205182443152,
|
|
0.00134661998384056,
|
|
0.00143657520471197,
|
|
0.00136147038801906,
|
|
0.00164744645799012,
|
|
0.00159667890787163,
|
|
0.00139684313451599,
|
|
0.00157035175879397,
|
|
0.00137400384721077,
|
|
0.00126119308866187,
|
|
0.0011832919181162,
|
|
0.00124440019910403,
|
|
0.00118708452041785,
|
|
0.00120569086086328,
|
|
0.00117855038302887,
|
|
0.00111358574610245,
|
|
0.00134661998384056,
|
|
0.00131630906936949,
|
|
0.00128932439401754,
|
|
0.00118948495301534,
|
|
0.00116455106556423,
|
|
0.00117096018735363,
|
|
0.00126984126984127,
|
|
0.00118063754427391,
|
|
0.00115353558657285,
|
|
0.00133386688008537,
|
|
0.00140884756269372,
|
|
0.00152998776009792,
|
|
0.00145623998835008,
|
|
0.00139217597104274,
|
|
0.00133832976445396,
|
|
0.00132310134956338,
|
|
0.00138966092273485,
|
|
0.00136314067611778,
|
|
0.00141502759303806,
|
|
0.00131457867753385,
|
|
0.00151103052281656,
|
|
0.00142918393597256,
|
|
0.00133832976445396,
|
|
0.00145581598485951,
|
|
0.0016246953696182,
|
|
0.00159058374423413,
|
|
0.0015053439710974,
|
|
0.00156421085562334,
|
|
0.00140449438202247,
|
|
0.00135007425408397,
|
|
0.00181587071000545,
|
|
0.00159540523292916,
|
|
0.00149387511204063,
|
|
0.00153209744139727,
|
|
0.00159464200287036,
|
|
0.0014760147601476,
|
|
0.00146434324205594,
|
|
0.00162048290390536,
|
|
0.00147058823529412,
|
|
0.00149655791679138,
|
|
0.00155231294628997,
|
|
0.00139159476760367,
|
|
0.00164257555847569,
|
|
0.00163961305131989,
|
|
0.00194704049844237,
|
|
0.00153045607591062,
|
|
0.00143988480921526,
|
|
0.00182915675873422,
|
|
0.00178412132024978,
|
|
0.00161550888529887,
|
|
0.00166805671392827,
|
|
0.00150806816468104,
|
|
0.00214086919289231,
|
|
0.00152114390021296,
|
|
0.0014585764294049,
|
|
0.00154416306361952,
|
|
0.00155908949173683,
|
|
0.00165261940175178,
|
|
0.00191460846256941,
|
|
0.00176616036736136,
|
|
0.00157903047528817,
|
|
0.00153350713080816,
|
|
0.00172413793103448,
|
|
0.00178635226866738,
|
|
0.00167056465085199,
|
|
0.00176991150442478,
|
|
0.00169808116827984,
|
|
0.00189035916824197,
|
|
0.00171174255391989,
|
|
0.00171556013038257,
|
|
0.00158856235107228,
|
|
0.00168208578637511,
|
|
0.00169348010160881,
|
|
0.00165645188007288,
|
|
0.00175469380593087,
|
|
0.00173070266528211,
|
|
0.00176865935620799,
|
|
0.00168435236651508,
|
|
0.00172622130157086,
|
|
0.00169721656483367,
|
|
0.00177872643187478,
|
|
0.00176740897843761,
|
|
0.00175500175500176,
|
|
0.00174489617867737,
|
|
0.00177085177970604,
|
|
0.00161420500403551,
|
|
0.00169577751399016,
|
|
0.00185425551641016,
|
|
0.00165343915343915,
|
|
0.00164311534669734,
|
|
0.0019105846388995,
|
|
0.001822821728035,
|
|
0.00173160173160173,
|
|
0.00179856115107914,
|
|
0.0018618506795755,
|
|
0.00190331176246669,
|
|
0.0018828845791753,
|
|
0.00179307871615564,
|
|
0.0017636684303351,
|
|
0.00164527805199079,
|
|
0.00158127767235927,
|
|
0.00157331655129012,
|
|
0.00160849284220685,
|
|
0.00157529930686831,
|
|
0.00145285485979951,
|
|
0.00139879703455029,
|
|
0.00159846547314578,
|
|
0.0016249593760156,
|
|
0.00147188695908154,
|
|
0.00155376009944065,
|
|
0.00164095831965868,
|
|
0.0015044380923725,
|
|
0.0015938795027096,
|
|
0.00151584053357587,
|
|
0.00167168171180207,
|
|
0.001669727834363,
|
|
0.00170068027210884,
|
|
0.00176335743255158,
|
|
0.00157703832203123,
|
|
0.0016273393002441,
|
|
0.00161786118751011,
|
|
0.00147907114332199,
|
|
0.00149767859817283,
|
|
0.00165562913907285,
|
|
0.00154631204577084,
|
|
0.00150060024009604,
|
|
0.00147383935151069,
|
|
0.00171732783788425,
|
|
0.0016249593760156
|
|
);
|
|
|
|
sort($samples, SORT_NUMERIC);
|
|
}
|
|
else
|
|
{
|
|
$file = fopen($samples_file["tmp_name"], "r");
|
|
$samples = iterator_to_array(read_all_samples($file));
|
|
$samples = array_filter($samples, function ($x) { return $x > 1e-6; }); # remove all values less than 1us.
|
|
sort($samples, SORT_NUMERIC);
|
|
fclose($file);
|
|
}
|
|
|
|
$median = median($samples);
|
|
$mean = mean($samples);
|
|
$std = std($samples, $mean);
|
|
$low = $mean + 2 * $std;
|
|
|
|
$Y = gradefunc(1/$median) - $penalty;
|
|
$y = gradefunc(1/$low) - $penalty;
|
|
|
|
$LY = grade2letter($Y);
|
|
$Ly = grade2letter($y);
|
|
|
|
$minftime = $samples[0];
|
|
$minfps = 1/$minftime;
|
|
|
|
$samplesms = array();
|
|
array_walk($samples, function ($x) use(&$samplesms) { array_push($samplesms, 1000 * $x); });
|
|
$hist = hist($samplesms, 1000 * $std);
|
|
|
|
// print "<div class=\"no-print\">";
|
|
// print "debug:<br>";
|
|
// printf("median: %0.2f ms (%0.0f fps)<br>", $median * 1000, 1/$median);
|
|
// printf("mean: %0.2f ms (%0.0f fps)<br>", $mean * 1000, 1/$mean);
|
|
// printf("std: %0.2f ms<br>", $std * 1000);
|
|
// printf("low: %0.2f ms (%0.0f fps)<br>", $low * 1000, 1/$low);
|
|
// printf("grade: %s (%s)", grade2letter($Y), grade2letter($y));
|
|
// print "</div>";
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Source code available at https://git.mixedup.dev/themixedupstuff/1000fps -->
|
|
<head>
|
|
<meta charset="utf8">
|
|
<title>1000fps Report Card</title>
|
|
|
|
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
<script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js'></script>
|
|
|
|
<link href="https://fonts.googleapis.com/css2?family=Recursive:CRSV@0&display=swap" rel="stylesheet">
|
|
<link href="style.css" rel="stylesheet">
|
|
<link rel="icon" type="image/png" href="favicon.ico">
|
|
|
|
<script>
|
|
let firefox_wait_css = 1;
|
|
|
|
addEventListener("load", (ev) => {
|
|
const ctx = document.getElementById('histogram').getContext('2d');
|
|
// ctx.scale(2, 2);
|
|
|
|
const chart = new Chart(ctx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: [<?php
|
|
foreach ($hist as $row) {
|
|
printf("\"%s\",", $row[0]);
|
|
}
|
|
?>],
|
|
datasets: [{
|
|
label: "Frame Time (ms)",
|
|
data: [
|
|
<?php
|
|
foreach ($hist as $row) {
|
|
printf("\"%f\",", $row[1]);
|
|
}
|
|
?>
|
|
],
|
|
backgroundColor: "#e8b5ff",
|
|
}],
|
|
},
|
|
options: {
|
|
responsive: false
|
|
}
|
|
});
|
|
|
|
// ctx.scale(0.5, 0.5);
|
|
});
|
|
</script>
|
|
<style>
|
|
@media print {
|
|
.no-print {
|
|
display: none;
|
|
}
|
|
|
|
html
|
|
{
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: unset;
|
|
}
|
|
|
|
body {
|
|
margin: auto;
|
|
max-width: inherit;
|
|
box-shadow: unset;
|
|
background-color: white;
|
|
padding: 0;
|
|
}
|
|
|
|
.page-break {
|
|
break-after: page;
|
|
}
|
|
}
|
|
|
|
body {
|
|
padding: 0;
|
|
}
|
|
|
|
body > div {
|
|
padding: 0;
|
|
}
|
|
|
|
div {
|
|
padding: 10pt;
|
|
}
|
|
|
|
.page {
|
|
min-width: 170mm;
|
|
min-height: 255mm;
|
|
padding: 0;
|
|
|
|
text-align: center;
|
|
|
|
border: 4pt #5f517b solid;
|
|
|
|
background-image: url("1000fps_watermark.svg");
|
|
background-size: 150pt;
|
|
background-position: 95% 95%;
|
|
background-repeat: no-repeat;
|
|
}
|
|
|
|
#mainmatter hr {
|
|
max-width: 300pt;
|
|
}
|
|
|
|
#title {
|
|
|
|
padding-left: 0;
|
|
padding-right: 0;
|
|
background-color: #c4b5e1;
|
|
}
|
|
|
|
#title h6 {
|
|
margin: auto;
|
|
}
|
|
|
|
#title h1 {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
#title #logo {
|
|
max-height: 4em;
|
|
margin: 4pt;
|
|
}
|
|
|
|
table {
|
|
margin-top: 8pt;
|
|
}
|
|
|
|
#mainmatter #time-table {
|
|
margin-top: 36pt
|
|
}
|
|
|
|
#grade {
|
|
font-size: 3em;
|
|
}
|
|
|
|
#grade #low-grade {
|
|
font-size: 0.5em;
|
|
}
|
|
|
|
canvas {
|
|
margin: auto;
|
|
/* width: 480pt; */
|
|
/* height: 320pt; */
|
|
}
|
|
|
|
.left-align {
|
|
text-align: left;
|
|
margin: auto;
|
|
}
|
|
|
|
.small {
|
|
font-size: 0.75em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<div class="no-print">
|
|
<?php if ($preview_mode) print "<p>PREVIEW MODE</p>"; ?>
|
|
<p>
|
|
You can print this web page as is. Print to PDF if you would like a file.
|
|
<input type="button" onclick="window.print()" value="Print">
|
|
</p>
|
|
</div>
|
|
<div class="page" id="mainmatter">
|
|
<div id="title">
|
|
<h6>The Unofficial 1000fps Club Presents</h6>
|
|
<h1 >
|
|
<object id="logo" data="1000fps.svg" type="image/svg+xml"></object>
|
|
Certificate
|
|
</h1>
|
|
</div>
|
|
|
|
<p><?php
|
|
if ($Y > 4)
|
|
print "We certify the appliaction or game, for its excellence";
|
|
else if ($Y < 1)
|
|
print "We regret to inform you that";
|
|
else
|
|
print "We certify the application or game";
|
|
?></p>
|
|
|
|
<h2><?php print $app_title; ?></h2>
|
|
|
|
<?php
|
|
if (!empty($app_author))
|
|
{
|
|
print "<p>Developed by ".$app_author."</p>";
|
|
}
|
|
?>
|
|
|
|
<p><?php
|
|
if ($y > 1)
|
|
print "has met the requirements to qualify as";
|
|
else
|
|
print "has failed to meet the requirements and received the grade"
|
|
?></p>
|
|
|
|
<div id="grade">
|
|
Grade
|
|
<span id="median-grade"><?php print $LY?></span><span id="low-grade">(<?php print $LY?>)</span>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<table id="time-table">
|
|
<thead>
|
|
<th>Parameter</th>
|
|
<th>Time</th>
|
|
<th>FPS</th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Median</td>
|
|
<td><?php printf("%.3f ms", 1000 * $median); ?></td>
|
|
<td><?php printf("%d", 1/$median); ?></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>Low</td> <td><?php printf("%.3f ms", 1000 * $low); ?></td>
|
|
<td><?php printf("%d", 1/$low); ?></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>Best</td> <td><?php printf("%.3f ms", 1000 * $minftime); ?></td>
|
|
<td><?php printf("%d", $minfps); ?></td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
<td>Mean Frame Time</td> <td><?php printf("%.3f ms", 1000 * $mean); ?></td>
|
|
<td>Standard Deviation</td> <td><?php printf("%.3f", 1000 * $std); ?></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>Median Score</td> <td><?php printf("%.3fpt", $Y); ?></td>
|
|
<td>(Low Score)</td> <td><?php printf("%.3fpt", $y); ?></td>
|
|
</tr>
|
|
|
|
<?php
|
|
if ($penalty > 0)
|
|
{
|
|
print "<tr><td>Before Penalty</td><td>";
|
|
printf("%.3fpt %s", $Y+$penalty, grade2letter($Y+$penalty));
|
|
print "</td><td>Before Penalty</td><td>";
|
|
printf("%.3fpt (%s)", $y+$penalty, grade2letter($y+$penalty));
|
|
print "</td></tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
<td>Client Area</td>
|
|
<td><?php printf("%d by %d", $client_w, $client_h); ?></td>
|
|
</tbody>
|
|
</table>
|
|
|
|
<?php
|
|
if ($penalty > 0)
|
|
{
|
|
printf("<p>Penalized %.0fpts for: ", $penalty);
|
|
|
|
$values = array();
|
|
|
|
if ($client_w < 1280 || $client_h < 720)
|
|
array_push($values, "Client Area (5pt)");
|
|
|
|
if ($client_w < 1920 || $client_h < 1080)
|
|
array_push($values, "Client Area (1pt)");
|
|
|
|
if ($penalty_audio) array_push($values, "Audio (1pt)");
|
|
if ($penalty_stutters) array_push($values, "Stutters (1pt)");
|
|
|
|
print implode(", ", $values);
|
|
|
|
print ".</p>";
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
<div class="page-break"></div>
|
|
|
|
<div class="page">
|
|
<div class="left-align small">
|
|
<h3>Hardware Info</h3>
|
|
<p><?php if(empty($hw_info)) print "Not available."; else print $hw_info; ?></p>
|
|
</div>
|
|
|
|
<div class="left-align small">
|
|
<h3>Caveats</h3>
|
|
<p><?php if(empty($caveats)) print "None."; else print $hw_info; ?></p>
|
|
</div>
|
|
|
|
<div>
|
|
<h3>Histogram</h3>
|
|
<canvas id="histogram" width="480pt" height="320pt"></canvas>
|
|
</div>
|
|
|
|
<p>
|
|
For more information visit <a href="https://mixedup.dev/1000fps">https://mixedup.dev/1000fps</a>.
|
|
</p>
|
|
</div>
|
|
<div>
|
|
</body>
|
|
</html>
|