diff options
| author | Yoshiya Hinosawa <stibium121@gmail.com> | 2018-10-17 01:00:47 +0900 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-16 12:00:47 -0400 |
| commit | d4afbe6ef3206e53e2ddc7f59c6b90bbffcbe988 (patch) | |
| tree | a6bb14d790c0d7632bf8ba66f43ef4ab3f2ff8aa /website | |
| parent | a90cf4c2ee6a98a9f7b2cd58528e94d3f84e1f0d (diff) | |
improve benchmark page performance and fix test (#1002)
Diffstat (limited to 'website')
| -rw-r--r-- | website/app.js | 48 | ||||
| -rw-r--r-- | website/app_test.js | 14 |
2 files changed, 37 insertions, 25 deletions
diff --git a/website/app.js b/website/app.js index 595e95755..6eb727cd7 100644 --- a/website/app.js +++ b/website/app.js @@ -4,16 +4,16 @@ 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, { +export async function getTravisData( + url = "https://api.travis-ci.com/repos/denoland/deno/builds?event_type=pull_request" +) { + const res = await fetch(url, { headers: { Accept: "application/vnd.travis-ci.2.1+json" } - }) - .then(res => res.json()) - .then(data => data.builds.reverse()); + }); + const data = await res.json(); + return data.builds.reverse(); } function getBenchmarkVarieties(data, benchmarkName) { @@ -130,9 +130,16 @@ export function formatSeconds(t) { return a < 30 ? `${min} min` : `${min + 1} min`; } -export async function main() { +export function main() { + drawChartsFromBenchmarkData(); + drawChartsFromTravisData(); +} + +/** + * Draws the charts from the benchmark data stored in gh-pages branch. + */ +export async function drawChartsFromBenchmarkData() { const data = await getJson("./data.json"); - const travisData = (await getTravisData()).filter(d => d.duration > 0); const execTimeColumns = createExecTimeColumns(data); const throughputColumns = createThroughputColumns(data); @@ -140,10 +147,8 @@ export async function main() { const binarySizeColumns = createBinarySizeColumns(data); const threadCountColumns = createThreadCountColumns(data); const syscallCountColumns = createSyscallCountColumns(data); - const travisCompileTimeColumns = createTravisCompileTimeColumns(travisData); const sha1List = createSha1List(data); const sha1ShortList = sha1List.map(sha1 => sha1.substring(0, 6)); - const prNumberList = travisData.map(d => d.pull_request_number); const viewCommitOnClick = _sha1List => d => { window.open( @@ -151,12 +156,6 @@ export async function main() { ); }; - const viewPullRequestOnClick = _prNumberList => d => { - window.open( - `https://github.com/denoland/deno/pull/${_prNumberList[d["index"]]}` - ); - }; - c3.generate({ bindto: "#exec-time-chart", data: { @@ -260,6 +259,21 @@ export async function main() { } } }); +} + +/** + * Draws the charts from travis' API data. + */ +export async function drawChartsFromTravisData() { + const viewPullRequestOnClick = _prNumberList => d => { + window.open( + `https://github.com/denoland/deno/pull/${_prNumberList[d["index"]]}` + ); + }; + + const travisData = (await getTravisData()).filter(d => d.duration > 0); + const travisCompileTimeColumns = createTravisCompileTimeColumns(travisData); + const prNumberList = travisData.map(d => d.pull_request_number); c3.generate({ bindto: "#travis-compile-time-chart", diff --git a/website/app_test.js b/website/app_test.js index cebf78aeb..5edecc26e 100644 --- a/website/app_test.js +++ b/website/app_test.js @@ -1,6 +1,6 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, assert, assertEqual } from "../js/test_util.ts"; +import { test, testPerm, assert, assertEqual } from "../js/test_util.ts"; import { createBinarySizeColumns, createExecTimeColumns, @@ -209,11 +209,9 @@ test(function formatSecondsPatterns() { assertEqual(formatSeconds(10000), "167 min"); }); -test(async function getTravisDataSuccess() { - try { - const data = await getTravisData(); - assert(data.length !== 0); - } catch (e) { - assert(e !== null); - } +testPerm({ net: true }, async function getTravisDataSuccess() { + const data = await getTravisData( + "http://localhost:4545/tools/testdata/travis_benchmark.json" + ); + assert(data.length !== 0); }); |
