1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 04:48:52 -05:00

Benchmarks: github link and truncate sha1 (#845)

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2018-09-27 02:19:42 -04:00 committed by Ryan Dahl
parent c226e1b44e
commit c75b1b6237
2 changed files with 48 additions and 19 deletions

View file

@ -5,10 +5,11 @@ export async function getJson(path) {
}
export function getTravisData() {
const url = "https://api.travis-ci.com/repos/denoland/deno/builds?event_type=pull_request";
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"
Accept: "application/vnd.travis-ci.2.1+json"
}
})
.then(res => res.json())
@ -79,7 +80,7 @@ export function createSyscallCountColumns(data) {
]);
}
const travisCompileTimeNames = ["duration_time"]
const travisCompileTimeNames = ["duration_time"];
function createTravisCompileTimeColumns(data) {
const columnsData = travisCompileTimeNames.map(name => [
name,
@ -119,26 +120,45 @@ export async function main() {
const syscallCountColumns = createSyscallCountColumns(data);
const travisCompileTimeColumns = createTravisCompileTimeColumns(travisData);
const sha1List = createSha1List(data);
const sha1SuffixList = sha1List.map(sha1 => sha1.substring(sha1.length - 6));
const prNumberList = travisData.map(d => d.pull_request_number);
const viewCommitOnClick = _sha1List => d => {
window.open(
`https://github.com/denoland/deno/commit/${_sha1List[d["index"]]}`
);
};
const viewPullRequestOnClick = _prNumberList => d => {
window.open(
`https://github.com/denoland/deno/pull/${_prNumberList[d["index"]]}`
);
};
c3.generate({
bindto: "#exec-time-chart",
data: { columns: execTimeColumns },
data: {
columns: execTimeColumns,
onclick: viewCommitOnClick(sha1List)
},
axis: {
x: {
type: "category",
categories: sha1List
categories: sha1SuffixList
}
}
});
c3.generate({
bindto: "#binary-size-chart",
data: { columns: binarySizeColumns },
data: {
columns: binarySizeColumns,
onclick: viewCommitOnClick(sha1List)
},
axis: {
x: {
type: "category",
categories: sha1List
categories: sha1SuffixList
},
y: {
tick: {
@ -150,33 +170,42 @@ export async function main() {
c3.generate({
bindto: "#thread-count-chart",
data: { columns: threadCountColumns },
data: {
columns: threadCountColumns,
onclick: viewCommitOnClick(sha1List)
},
axis: {
x: {
type: "category",
categories: sha1List
categories: sha1SuffixList
}
}
});
c3.generate({
bindto: "#syscall-count-chart",
data: { columns: syscallCountColumns },
data: {
columns: syscallCountColumns,
onclick: viewCommitOnClick(sha1List)
},
axis: {
x: {
type: "category",
categories: sha1List
categories: sha1SuffixList
}
}
});
c3.generate({
bindto: "#travis-compile-time-chart",
data: { columns: travisCompileTimeColumns },
data: {
columns: travisCompileTimeColumns,
onclick: viewPullRequestOnClick(prNumberList)
},
axis: {
x: {
type: "category",
categories: travisData.map(d => d.pull_request_number)
categories: prNumberList
},
y: {
tick: {

View file

@ -9,7 +9,7 @@ import {
createSha1List,
formatBytes,
formatSeconds,
getTravisData,
getTravisData
} from "./app.js";
const regularData = [
@ -176,7 +176,7 @@ test(function formatSecondsPatterns() {
assertEqual(formatSeconds(100), "2 min");
assertEqual(formatSeconds(1000), "17 min");
assertEqual(formatSeconds(10000), "167 min");
})
});
test(async function getTravisDataSuccess() {
try {