This commit is contained in:
Hannes Verschore 2017-03-23 08:02:26 -07:00
Родитель fb339cdf94
Коммит f0e23c3bd3
8 изменённых файлов: 250 добавлений и 10 удалений

Просмотреть файл

@ -24,6 +24,7 @@
<div class='rightSide'>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/overview"><span>Overview</span></a></div>
<div><a href="/schedule.php"><span>Schedule</span></a></div>
</div>
</div>
</header>
@ -192,8 +193,8 @@ while($unit = mysql_fetch_object($qUnits)) {
if ($task->hasError()) {
$color = "red";
} elseif ($task->finish_time() > 0) {
if ($task->finish_time() - $task->start_time() < 5*60)
$color = "red";
if (strpos($task->output(), "Traceback") !== false)
$color = "orange";
else
$color = "green";
} elseif ($task->start_time() > 0) {

Просмотреть файл

@ -36,6 +36,7 @@
<div class='rightSide'>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/overview"><span>Overview</span></a></div>
<div><a href="/schedule.php"><span>Schedule</span></a></div>
<!--
<div><a href="/regressions"><span>Regressions</span></a></div>
<div class='userMenu'>

Просмотреть файл

@ -74,5 +74,17 @@ class QueuedTask extends DB {
function error() {
return $this->select("error");
}
static function insert($control_unit_id, $task, $email) {
$control_unit_id = (int)$control_unit_id;
$task = mysql_real_escape_string($task);
$email = mysql_real_escape_string($email);
mysql_query("INSERT INTO control_task_queue
(control_unit_id, task, email)
VALUES
($control_unit_id, '$task', '$email')");
return mysql_insert_id();
}
}

Просмотреть файл

@ -0,0 +1,108 @@
<?php
require_once("DB.php");
require_once("Mode.php");
require_once("Machine.php");
class TaskRecipe extends DB {
public static $db = "control_task_recipe";
public function __construct($id) {
$this->id = $id;
}
public function name() {
return $this->select("name");
}
public function description() {
return $this->select("description");
}
public function task() {
return $this->select("task");
}
public function control_unit_id() {
return $this->select("control_unit_id");
}
public function inputs() {
$inputs = [];
$task = $this->task();
if (strpos($task, "{revision}") !== false) {
$inputs[] = array(
"id" => "revision",
"type" =>"alphanum",
"name" => "Revision",
);
}
if (strpos($task, "{repo}") !== false) {
$inputs[] = array(
"id" => "repo",
"type" => "select",
"name" => "Repository",
"options" => ["mozilla-try", "mozilla-inbound", "mozilla-aurora", "mozilla-beta"]
);
}
if (strpos($task, "{shell_repo}") !== false) {
$inputs[] = array(
"id" => "shell_repo",
"type" => "select",
"name" => "Repository",
"options" => ["mozilla-try", "mozilla"]
);
}
if (strpos($task, "{browser_benchmark}") !== false) {
$inputs[] = array(
"id" => "browser_benchmark",
"type" => "select",
"name" => "Benchmark",
"options" => ["remote.octane", "remote.dromaeo", "remote.massive",
"remote.jetstream", "remote.speedometer", "remote.speedometer-misc",
"remote.kraken", "remote.sunspider", "remote.browsermark",
"remote.wasm"]
);
}
if (strpos($task, "{shell_benchmark}") !== false) {
$inputs[] = array(
"id" => "shell_benchmark",
"type" => "select",
"name" => "Benchmark",
"options" => ["shell.octane", "shell.sunspider", "shell.kraken", "shell.assorted",
"shell.asmjsapps", "shell.asmjsmicro", "shell.dart", "shell.sixspeed"]
);
}
return $inputs;
}
function fill($values) {
$task = $this->task();
$inputs = $this->inputs();
foreach ($inputs as $input) {
if (!isset($values[$input["id"]]))
continue;
if ($input["type"] == "alphanum" && ctype_alnum($values[$input["id"]])) {
$task = str_replace("{".$input["id"]."}", $values[$input["id"]], $task);
continue;
}
if ($input["type"] == "select" && in_array($values[$input["id"]], $input["options"])) {
$task = str_replace("{".$input["id"]."}", $values[$input["id"]], $task);
continue;
}
}
return $task;
}
public static function all() {
$qTasks = mysql_query("SELECT id FROM control_task_recipe") or die(mysql_error());
$tasks = Array();
while ($task = mysql_fetch_object($qTasks)) {
$tasks[] = new TaskRecipe($task->id);
}
return $tasks;
}
}

Просмотреть файл

@ -27,8 +27,9 @@
<div class='container'>
<h1><a href='#'>AreWeFastYet</a></h1>
<div class='rightSide'>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/"><span>Graphs</span></a></div>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/schedule.php"><span>Schedule</span></a></div>
<div class='userMenu'>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</div>

35
website/schedule.js Normal file
Просмотреть файл

@ -0,0 +1,35 @@
function init_schedule() {
var html = "<select onchange='init_recipe(this.value)'>";
html += "<option value='-1'>---</option>";
for (var i = 0; i < recipes.length; i++) {
html += "<option value='"+i+"'>"+recipes[i]["name"]+"</option>";
}
html += "</select>";
html += "<div id='recipe_content'></div";
document.getElementsByClassName("dashboard_content")[0].innerHTML = html;
}
function init_recipe(id) {
var html = "<p>"+recipes[id]["description"]+"</p>";
html += "<input type='hidden' name='task' value='"+recipes[id]["id"]+"'>";
html += "<textarea disabled cols=100 rows=5>"+recipes[id]["task"]+"</textarea><br/>";
var inputs = recipes[id]["inputs"]
for (var i = 0; i < inputs.length; i++) {
var id = inputs[i]["id"]
if (inputs[i]["type"] == "alphanum") {
html += inputs[i]["name"]+": <input name='"+id+"' type='text' value='' /><br />";
} else if (inputs[i]["type"] == "select") {
html += inputs[i]["name"]+": ";
html += "<select name='"+id+"'>";
for (var j = 0; j < inputs[i]["options"].length; j++) {
html += "<option>"+inputs[i]["options"][j]+"</option>";
}
html += "</select><br />";
}
}
html += "Email results: <input name='email' type='checkbox' checked><br />";
html += "<input type='submit' value='schedule'>";
document.getElementById('recipe_content').innerHTML = html;
}

79
website/schedule.php Normal file
Просмотреть файл

@ -0,0 +1,79 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-language" content="en">
<title>ARE WE FAST YET?</title>
<link rel="stylesheet" title="Default Stylesheet" type="text/css" href="style.css">
<link rel="shortcut icon" href="//www.arewefastyet.com/awfy_favicon.png">
<link href='//fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="jquery/jquery.ba-hashchange.min.js"></script>
<script type="text/javascript" src="flot/jquery.flot.js"></script>
<script type="text/javascript" src="flot/jquery.flot.selection.js"></script>
<script type="text/javascript" src="data.php?file=master.js"></script>
<script type="text/javascript" src="awfy.js"></script>
<script type="text/javascript" src="frontpage.js"></script>
<script type="text/javascript" src="tooltip.js"></script>
</head>
<body>
<header>
<div class='container'>
<h1><a href='#'>AreWeFastYet</a></h1>
<div class='rightSide'>
<div><a href="/"><span>Graphs</span></a></div>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/overview"><span>Overview</span></a></div>
</div>
</div>
</header>
<div class='container content'>
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
require_once("lib/DB/QueuedTask.php");
require_once("lib/DB/TaskRecipe.php");
init_database();
if (!has_permissions()) {
die("You need to be logged in.");
} else if (isset($_POST["task"])) {
$recipe = new TaskRecipe((int)$_POST["task"]);
$task = $recipe->fill($_POST);
$email = isset($_POST["email"]) ? username() : "";
$id = QueuedTask::insert($recipe->control_unit_id(), $task, $email);
echo "Task submitted. <br />Results will become visible on <a href='https://arewefastyet.com/task_info.php?id=$id'>https://arewefastyet.com/task_info.php?id=$id</a>";
} else {
$recipes = TaskRecipe::all();
$recipes_json = [];
foreach ($recipes as $recipe) {
$recipes_json[] = array(
"id" => $recipe->id,
"name" => $recipe->name(),
"description" => $recipe->description(),
"task" => $recipe->task(),
"inputs" => $recipe->inputs()
);
}
?>
<script>
var recipes = <?php echo json_encode($recipes_json); ?>
</script>
<form method=POST>
<h2>Schedule a task</h2>
<div class='dashboard_content'></div>
<script src='schedule.js'></script>
<script>init_schedule();</script>
</form>
<?php
}
?>
</div>

Просмотреть файл

@ -24,6 +24,7 @@
<div class='rightSide'>
<div><a href="http://h4writer.com"><span>Blog</span></a></div>
<div><a href="/overview"><span>Overview</span></a></div>
<div><a href="/schedule.php"><span>Schedule</span></a></div>
</div>
</div>
</header>
@ -80,7 +81,8 @@ if ($task_id = GET_int("id")) {
$task = new QueuedTask($task_id);
echo "<h1>Task ".$task->id."</h1>";
echo "Available from: ".print_time($task->available_time())."</br>";
if ($task->available_time() != 0)
echo "Available from: ".print_time($task->available_time())."</br>";
echo "Started time: ".print_time($task->start_time())."</br>";
echo "Finished time: ".print_time($task->finish_time())."</br>";
@ -107,13 +109,15 @@ if ($task_id = GET_int("id")) {
<script>
var results = {}
var output = document.getElementById("output").innerHTML;
var re = /Added mode [a-zA-Z0-9]* \(engine: [a-zA-Z0-9]*, config: [a-zA-Z0-9,-]*, changeset: [a-zA-Z0-9]*\)/g
var re = /[\*]{1,}/g;
var re = /[\*]{3,}/g;
while ((match = re.exec(output)) !== null) {
var data = output.substr(re.lastIndex + 1);
var newline = /\n/g;
var start = 0;
var revision = data.match(/changeset: ([a-zA-Z0-9]*)/)[1]
var revision = data.match(/changeset: ([a-zA-Z0-9]*)/)
if (!revision)
continue;
revision = revision[1]
if (!results[revision])
results[revision] = {}
@ -121,7 +125,6 @@ if ($task_id = GET_int("id")) {
while ((match = newline.exec(data)) !== null) {
var end = match.index;
var line = data.substring(start, end);
var result = line.match(/([a-zA-Z0-9,_-])* \(([a-zA-Z0-9,_ ])* -- [a-zA-Z0-9]*\): ([0-9.])*/)
var result = line.match(/([a-zA-Z0-9,_-]*) \(([a-zA-Z0-9,_. ]*) -- [a-zA-Z0-9]*\): ([0-9.]*)/)
if (result) {
@ -136,7 +139,6 @@ if ($task_id = GET_int("id")) {
}
var html = "<h2>Results:</h2><table>";
console.log(results);
for (revision in results) {
html += "<h3>Revision: "+revision+"</h3>";
for (benchmark in results[revision]) {
@ -148,7 +150,8 @@ if ($task_id = GET_int("id")) {
html += "</table>";
}
}
document.getElementById("results").innerHTML = html;
if (Object.keys(results).length != 0)
document.getElementById("results").innerHTML = html;
</script>
<?php }?>
</div>