0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

Travis benchmark (#832)

This commit is contained in:
ztplz 2018-09-27 08:26:34 +08:00 committed by Ryan Dahl
parent 1e390e69cd
commit c226e1b44e
3 changed files with 67 additions and 2 deletions

View file

@ -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)
}
}
}
});
}

View file

@ -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);
}
});

View file

@ -13,6 +13,8 @@
<div id="thread-count-chart"></div>
<h2>Syscall count</h2>
<div id="syscall-count-chart"></div>
<h2>Travis compile time</h2>
<div id="travis-compile-time-chart"></div>
<script src="https://unpkg.com/d3@5.7.0/dist/d3.min.js"></script>
<script src="https://unpkg.com/c3@0.6.7/c3.min.js"></script>
<script type="module">