Exemplo n.º 1
0
function print_benchmark_details($rev, $old_rev)
{
    global $DB, $td, $th, $benchmark_order;
    # fetch the current revisions data
    $test_data = $DB->query("\n\t\t\t\tSELECT\trevision, name, metric, result\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\trevision == {$rev}\n\t\t\t\t")->fetchAll(PDO::FETCH_ASSOC);
    print "<table class=info>";
    print "<tr>" . "<th>Benchmark</th>" . "<th>Metric</th>" . "<th>Result (+/- vs " . "<a href='details.php?rev={$old_rev}'>{$old_rev}</a>" . ")</th>";
    # fetch the previous revisions data, for comparison
    $old_test_data = $DB->query("\n\t\t\t\tSELECT\trevision, name, metric, result\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\trevision == {$old_rev}\n\t\t\t\t")->fetchAll(PDO::FETCH_ASSOC);
    # process data
    foreach ($test_data as &$row) {
        $old_row = array_shift($old_test_data);
        $row["difference"] = add_percentage_difference("result", $row, $old_row);
    }
    unset($row);
    // release the reference to $row
    $test_data = order_by($test_data, $benchmark_order, "metric");
    # print
    foreach ($test_data as $row_set) {
        foreach ($row_set as $row) {
            unset($row["revision"]);
            # pick a color
            $color = "";
            if ($row["difference"] > 0) {
                $color = get_bad_color();
            } elseif ($row["difference"] < 0) {
                $color = get_good_color();
            }
            unset($row["difference"]);
            print "<tr>\n";
            foreach ($row as $key => $entry) {
                print "<td {$color}>{$entry}</td>";
            }
            print "</tr>\n";
        }
    }
    print "</table>";
}
Exemplo n.º 2
0
function run_main()
{
    global $DB;
    $order = array("revision", "branch", "author", "pass", "fail", "skip", "timeout", "benchmark", "time_taken", "test_date", "revision_used", "failed", "redo");
    foreach ($order as $header) {
        $headers[$header] = ucfirst(str_replace("_", " ", $header));
    }
    $headers["revision"] = "Rev";
    $headers["revision_used"] = "Test rev";
    $headers["time_taken"] = "Time";
    $headers["benchmark"] = "Bench";
    $headers["timeout"] = "T/O";
    print "<table class=info>\n";
    print "<tr>\n";
    foreach (array_values($headers) as $header) {
        print "<th>{$header}</th>\n";
    }
    // Completed tests
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, branch, author\n\t\t\t\tFROM\t\tcomplete\n\t\t\t\t");
    $completes = $query->fetchAll(PDO::FETCH_ASSOC);
    // Test results
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, pass, fail, skip, timeout\n\t\t\t\tFROM\t\ttests\n\t\t\t\tWHERE\t\ttestname == 'Total'\n\t\t\t\t");
    $tests = $query->fetchAll(PDO::FETCH_ASSOC);
    // Benchmark results
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, result as benchmark\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\tmetric = 'All'\n\t\t\t\t");
    $benchmarks = $query->fetchAll(PDO::FETCH_ASSOC);
    // Compile meta-results
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'compile'\n\t\t\t\t");
    $compile_meta = $query->fetchAll(PDO::FETCH_ASSOC);
    // Test meta-results
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'test'\n\t\t\t\t");
    $test_meta = $query->fetchAll(PDO::FETCH_ASSOC);
    // Bench meta-results
    $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'benchmark'\n\t\t\t\t");
    $bench_meta = $query->fetchAll(PDO::FETCH_ASSOC);
    $query = $DB->query("SELECT revision FROM running");
    $running = $query->fetchAll(PDO::FETCH_ASSOC);
    $running = $running[0]["revision"];
    $revisions = array_reduce(array($completes, $tests, $benchmarks, $compile_meta, $test_meta, $bench_meta), "merge_results");
    ksort($revisions);
    # process data
    foreach ($revisions as $rev => &$data) {
        // Always use the correct branch for relative data
        $branch = $data["branch"];
        $data["difference"] = add_difference("pass", $data, $revisions[$prev[$branch]]);
        add_difference("fail", $data, $revisions[$prev[$branch]]);
        $prev[$branch] = $rev;
    }
    $revisions = array_reverse($revisions, true);
    # print out rows
    foreach ($revisions as $rev => $data) {
        print "<tr>\n";
        # pick a color
        $color = "";
        if ($data["difference"] > 0) {
            $color = get_good_color();
        } elseif ($data["difference"] < 0) {
            $color = get_bad_color();
        }
        unset($data["difference"]);
        if ($rev == $running) {
            $color = get_running_color();
        }
        # add a link to revision
        $data["revision"] = "<a href=\"details.php?rev={$rev}\">{$rev}</a>";
        if (isset($data["test_date"])) {
            $data["test_date"] = date_from_timestamp($data["test_date"]);
        }
        if (isset($data["time_taken"])) {
            $data["time_taken"] = minutes_from_seconds($data["time_taken"]);
        }
        foreach ($order as $header) {
            $value = $data[$header];
            print "<td {$color}>{$value}</td>\n";
        }
        print "<a/></tr>\n";
    }
}