mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
improve benchmark page performance and fix test (#1002)
This commit is contained in:
parent
a90cf4c2ee
commit
d4afbe6ef3
3 changed files with 3096 additions and 25 deletions
3059
tools/testdata/travis_benchmark.json
vendored
Normal file
3059
tools/testdata/travis_benchmark.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
testPerm({ net: true }, async function getTravisDataSuccess() {
|
||||
const data = await getTravisData(
|
||||
"http://localhost:4545/tools/testdata/travis_benchmark.json"
|
||||
);
|
||||
assert(data.length !== 0);
|
||||
} catch (e) {
|
||||
assert(e !== null);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue