diff --git a/website/app.js b/website/app.js index 31aa993493..c1a263eac4 100644 --- a/website/app.js +++ b/website/app.js @@ -4,6 +4,17 @@ export async function getJson(path) { return (await fetch(path)).json(); } +export function getTravisData() { + const url = "https://api.travis-ci.com/repos/denoland/deno/builds?event_type=pull_request"; + return fetch(url, { + headers: { + "Accept": "application/vnd.travis-ci.2.1+json" + } + }) + .then(res => res.json()) + .then(data => data.builds.reverse()); +} + const benchmarkNames = [ "hello", "relative_import", @@ -68,6 +79,15 @@ export function createSyscallCountColumns(data) { ]); } +const travisCompileTimeNames = ["duration_time"] +function createTravisCompileTimeColumns(data) { + const columnsData = travisCompileTimeNames.map(name => [ + name, + ...data.map(d => d.duration) + ]); + return columnsData; +} + export function createSha1List(data) { return data.map(d => d.sha1); } @@ -83,14 +103,23 @@ export function formatBytes(a, b) { return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f]; } +export function formatSeconds(t) { + const a = t % 60; + const min = Math.floor(t / 60); + return a < 30 ? `${min} min` : `${min + 1} min`; +} + export async function main() { const data = await getJson("./data.json"); + const travisData = (await getTravisData()).filter(d => d.duration > 0); const execTimeColumns = createExecTimeColumns(data); const binarySizeColumns = createBinarySizeColumns(data); const threadCountColumns = createThreadCountColumns(data); const syscallCountColumns = createSyscallCountColumns(data); + const travisCompileTimeColumns = createTravisCompileTimeColumns(travisData); const sha1List = createSha1List(data); + c3.generate({ bindto: "#exec-time-chart", @@ -140,4 +169,20 @@ export async function main() { } } }); + + c3.generate({ + bindto: "#travis-compile-time-chart", + data: { columns: travisCompileTimeColumns }, + axis: { + x: { + type: "category", + categories: travisData.map(d => d.pull_request_number) + }, + y: { + tick: { + format: d => formatSeconds(d) + } + } + } + }); } diff --git a/website/app_test.js b/website/app_test.js index e0d1a49698..d6e9b4d81e 100644 --- a/website/app_test.js +++ b/website/app_test.js @@ -1,13 +1,15 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, assertEqual } from "../js/test_util.ts"; +import { test, assert, assertEqual } from "../js/test_util.ts"; import { createBinarySizeColumns, createExecTimeColumns, createThreadCountColumns, createSyscallCountColumns, createSha1List, - formatBytes + formatBytes, + formatSeconds, + getTravisData, } from "./app.js"; const regularData = [ @@ -168,3 +170,19 @@ test(function formatBytesPatterns() { assertEqual(formatBytes(180000000), "171.66 MB"); assertEqual(formatBytes(18000000000), "16.76 GB"); }); + +test(function formatSecondsPatterns() { + assertEqual(formatSeconds(10), "0 min"); + assertEqual(formatSeconds(100), "2 min"); + assertEqual(formatSeconds(1000), "17 min"); + assertEqual(formatSeconds(10000), "167 min"); +}) + +test(async function getTravisDataSuccess() { + try { + const data = await getTravisData(); + assert(data.length !== 0); + } catch (e) { + assert(e !== null); + } +}); diff --git a/website/index.html b/website/index.html index 52cfdc442a..195f6869fa 100644 --- a/website/index.html +++ b/website/index.html @@ -13,6 +13,8 @@

Syscall count

+

Travis compile time

+