2018-09-24 11:31:14 -04:00
|
|
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
export async function getJson(path) {
|
|
|
|
return (await fetch(path)).json();
|
|
|
|
}
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2018-10-16 12:00:47 -04:00
|
|
|
export async function getTravisData(
|
|
|
|
url = "https://api.travis-ci.com/repos/denoland/deno/builds?event_type=pull_request"
|
|
|
|
) {
|
|
|
|
const res = await fetch(url, {
|
2018-09-26 20:26:34 -04:00
|
|
|
headers: {
|
2018-09-27 02:19:42 -04:00
|
|
|
Accept: "application/vnd.travis-ci.2.1+json"
|
2018-09-26 20:26:34 -04:00
|
|
|
}
|
2018-10-16 12:00:47 -04:00
|
|
|
});
|
|
|
|
const data = await res.json();
|
|
|
|
return data.builds.reverse();
|
2018-09-26 20:26:34 -04:00
|
|
|
}
|
|
|
|
|
2018-10-11 16:55:22 -04:00
|
|
|
function getBenchmarkVarieties(data, benchmarkName) {
|
|
|
|
// Look at last sha hash.
|
|
|
|
const last = data[data.length - 1];
|
|
|
|
return Object.keys(last[benchmarkName]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createColumns(data, benchmarkName) {
|
|
|
|
const varieties = getBenchmarkVarieties(data, benchmarkName);
|
|
|
|
return varieties.map(variety => [
|
|
|
|
variety,
|
2018-09-21 12:06:59 -04:00
|
|
|
...data.map(d => {
|
2018-10-11 16:55:22 -04:00
|
|
|
if (d[benchmarkName] != null) {
|
|
|
|
if (d[benchmarkName][variety] != null) {
|
|
|
|
const v = d[benchmarkName][variety];
|
|
|
|
if (benchmarkName == "benchmark") {
|
|
|
|
const meanValue = v ? v.mean : 0;
|
|
|
|
return meanValue || null;
|
|
|
|
} else {
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2018-09-21 12:06:59 -04:00
|
|
|
})
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
|
2018-10-11 16:55:22 -04:00
|
|
|
export function createExecTimeColumns(data) {
|
|
|
|
return createColumns(data, "benchmark");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createThroughputColumns(data) {
|
|
|
|
return createColumns(data, "throughput");
|
|
|
|
}
|
|
|
|
|
2018-10-15 16:44:35 -04:00
|
|
|
export function createReqPerSecColumns(data) {
|
|
|
|
return createColumns(data, "req_per_sec");
|
|
|
|
}
|
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
export function createBinarySizeColumns(data) {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "binary_size";
|
|
|
|
const binarySizeNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-25 20:08:09 -04:00
|
|
|
return binarySizeNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
|
|
|
const binarySizeData = d["binary_size"];
|
|
|
|
switch (typeof binarySizeData) {
|
|
|
|
case "number": // legacy implementation
|
|
|
|
return name === "deno" ? binarySizeData : 0;
|
|
|
|
default:
|
|
|
|
if (!binarySizeData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-25 20:08:09 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return binarySizeData[name] || null;
|
2018-09-25 20:08:09 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
|
2018-09-24 18:12:52 -04:00
|
|
|
export function createThreadCountColumns(data) {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "thread_count";
|
|
|
|
const threadCountNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-24 18:12:52 -04:00
|
|
|
return threadCountNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
2018-10-06 22:21:51 -04:00
|
|
|
const threadCountData = d[propName];
|
2018-09-24 18:12:52 -04:00
|
|
|
if (!threadCountData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-24 18:12:52 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return threadCountData[name] || null;
|
2018-09-24 18:12:52 -04:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2018-09-24 23:58:18 -04:00
|
|
|
export function createSyscallCountColumns(data) {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "syscall_count";
|
|
|
|
const syscallCountNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-24 23:58:18 -04:00
|
|
|
return syscallCountNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
2018-10-06 22:21:51 -04:00
|
|
|
const syscallCountData = d[propName];
|
2018-09-24 23:58:18 -04:00
|
|
|
if (!syscallCountData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-24 23:58:18 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return syscallCountData[name] || null;
|
2018-09-24 23:58:18 -04:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2018-09-26 20:26:34 -04:00
|
|
|
function createTravisCompileTimeColumns(data) {
|
2018-10-06 22:21:51 -04:00
|
|
|
return [["duration_time", ...data.map(d => d.duration)]];
|
2018-09-26 20:26:34 -04:00
|
|
|
}
|
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
export function createSha1List(data) {
|
|
|
|
return data.map(d => d.sha1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Formats the byte sizes e.g. 19000 -> 18.55 KB
|
|
|
|
// Copied from https://stackoverflow.com/a/18650828
|
|
|
|
export function formatBytes(a, b) {
|
|
|
|
if (0 == a) return "0 Bytes";
|
|
|
|
var c = 1024,
|
|
|
|
d = b || 2,
|
|
|
|
e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
|
|
f = Math.floor(Math.log(a) / Math.log(c));
|
|
|
|
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
|
|
|
|
}
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2018-09-26 20:26:34 -04:00
|
|
|
export function formatSeconds(t) {
|
|
|
|
const a = t % 60;
|
|
|
|
const min = Math.floor(t / 60);
|
2018-09-27 02:19:42 -04:00
|
|
|
return a < 30 ? `${min} min` : `${min + 1} min`;
|
2018-09-26 20:26:34 -04:00
|
|
|
}
|
|
|
|
|
2018-10-16 12:00:47 -04:00
|
|
|
export function main() {
|
|
|
|
drawChartsFromBenchmarkData();
|
|
|
|
drawChartsFromTravisData();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the charts from the benchmark data stored in gh-pages branch.
|
|
|
|
*/
|
|
|
|
export async function drawChartsFromBenchmarkData() {
|
2018-09-24 11:31:14 -04:00
|
|
|
const data = await getJson("./data.json");
|
|
|
|
|
|
|
|
const execTimeColumns = createExecTimeColumns(data);
|
2018-10-11 16:55:22 -04:00
|
|
|
const throughputColumns = createThroughputColumns(data);
|
2018-10-15 16:44:35 -04:00
|
|
|
const reqPerSecColumns = createReqPerSecColumns(data);
|
2018-09-24 11:31:14 -04:00
|
|
|
const binarySizeColumns = createBinarySizeColumns(data);
|
2018-09-24 18:12:52 -04:00
|
|
|
const threadCountColumns = createThreadCountColumns(data);
|
2018-09-24 23:58:18 -04:00
|
|
|
const syscallCountColumns = createSyscallCountColumns(data);
|
2018-09-24 11:31:14 -04:00
|
|
|
const sha1List = createSha1List(data);
|
2018-09-26 20:41:23 -04:00
|
|
|
const sha1ShortList = sha1List.map(sha1 => sha1.substring(0, 6));
|
2018-09-27 02:19:42 -04:00
|
|
|
|
|
|
|
const viewCommitOnClick = _sha1List => d => {
|
|
|
|
window.open(
|
|
|
|
`https://github.com/denoland/deno/commit/${_sha1List[d["index"]]}`
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-09-21 12:06:59 -04:00
|
|
|
c3.generate({
|
2018-09-23 11:54:07 -04:00
|
|
|
bindto: "#exec-time-chart",
|
2018-09-27 02:19:42 -04:00
|
|
|
data: {
|
|
|
|
columns: execTimeColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
2018-09-21 12:06:59 -04:00
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
2018-09-26 20:41:23 -04:00
|
|
|
show: false,
|
|
|
|
categories: sha1List
|
|
|
|
},
|
|
|
|
y: {
|
2018-09-30 11:14:44 -04:00
|
|
|
label: "seconds"
|
2018-09-21 12:06:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-09-23 11:54:07 -04:00
|
|
|
|
2018-10-11 16:55:22 -04:00
|
|
|
c3.generate({
|
|
|
|
bindto: "#throughput-chart",
|
|
|
|
data: {
|
|
|
|
columns: throughputColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
|
|
|
show: false,
|
|
|
|
categories: sha1ShortList
|
|
|
|
},
|
|
|
|
y: {
|
|
|
|
label: "seconds"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-10-15 16:44:35 -04:00
|
|
|
c3.generate({
|
|
|
|
bindto: "#req-per-sec-chart",
|
|
|
|
data: {
|
|
|
|
columns: reqPerSecColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
|
|
|
show: false,
|
|
|
|
categories: sha1ShortList
|
|
|
|
},
|
|
|
|
y: {
|
|
|
|
label: "seconds"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-23 11:54:07 -04:00
|
|
|
c3.generate({
|
|
|
|
bindto: "#binary-size-chart",
|
2018-09-27 02:19:42 -04:00
|
|
|
data: {
|
|
|
|
columns: binarySizeColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
2018-09-23 11:54:07 -04:00
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
2018-09-26 20:41:23 -04:00
|
|
|
show: false,
|
|
|
|
categories: sha1ShortList
|
2018-09-23 11:54:07 -04:00
|
|
|
},
|
|
|
|
y: {
|
|
|
|
tick: {
|
|
|
|
format: d => formatBytes(d)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-09-24 18:12:52 -04:00
|
|
|
|
|
|
|
c3.generate({
|
|
|
|
bindto: "#thread-count-chart",
|
2018-09-27 02:19:42 -04:00
|
|
|
data: {
|
|
|
|
columns: threadCountColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
2018-09-24 18:12:52 -04:00
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
2018-09-26 20:41:23 -04:00
|
|
|
show: false,
|
|
|
|
categories: sha1ShortList
|
2018-09-24 18:12:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-09-24 23:58:18 -04:00
|
|
|
|
|
|
|
c3.generate({
|
|
|
|
bindto: "#syscall-count-chart",
|
2018-09-27 02:19:42 -04:00
|
|
|
data: {
|
|
|
|
columns: syscallCountColumns,
|
|
|
|
onclick: viewCommitOnClick(sha1List)
|
|
|
|
},
|
2018-09-24 23:58:18 -04:00
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
2018-09-26 20:41:23 -04:00
|
|
|
show: false,
|
|
|
|
categories: sha1ShortList
|
2018-09-24 23:58:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-10-16 12:00:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2018-09-26 20:26:34 -04:00
|
|
|
|
|
|
|
c3.generate({
|
|
|
|
bindto: "#travis-compile-time-chart",
|
2018-09-27 02:19:42 -04:00
|
|
|
data: {
|
|
|
|
columns: travisCompileTimeColumns,
|
|
|
|
onclick: viewPullRequestOnClick(prNumberList)
|
|
|
|
},
|
2018-09-26 20:26:34 -04:00
|
|
|
axis: {
|
|
|
|
x: {
|
|
|
|
type: "category",
|
2018-09-27 02:19:42 -04:00
|
|
|
categories: prNumberList
|
2018-09-26 20:26:34 -04:00
|
|
|
},
|
|
|
|
y: {
|
|
|
|
tick: {
|
|
|
|
format: d => formatSeconds(d)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-09-23 11:54:07 -04:00
|
|
|
}
|