mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
refactor: stop hard coding some of benchmark names
This commit is contained in:
parent
48923f48a2
commit
1aa7e18ba3
3 changed files with 41 additions and 38 deletions
|
@ -1,6 +1,6 @@
|
||||||
## About benchmark data
|
## About benchmark data
|
||||||
|
|
||||||
The benchmark chart supposes `//website/data.json` has the signature of
|
The benchmark chart supposes `//website/data.json` has the type
|
||||||
`BenchmarkData[]` where `BenchmarkData` is defined like the below:
|
`BenchmarkData[]` where `BenchmarkData` is defined like the below:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
@ -16,9 +16,17 @@ interface ExecTimeData {
|
||||||
interface BenchmarkData {
|
interface BenchmarkData {
|
||||||
created_at: string;
|
created_at: string;
|
||||||
sha1: string;
|
sha1: string;
|
||||||
binary_size?: number;
|
|
||||||
benchmark: {
|
benchmark: {
|
||||||
[key: string]: ExecTimeData;
|
[key: string]: ExecTimeData;
|
||||||
};
|
};
|
||||||
|
binarySizeData: {
|
||||||
|
[key: string]: number;
|
||||||
|
};
|
||||||
|
threadCountData: {
|
||||||
|
[key: string]: number;
|
||||||
|
};
|
||||||
|
syscallCountData: {
|
||||||
|
[key: string]: number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -16,13 +16,8 @@ export function getTravisData() {
|
||||||
.then(data => data.builds.reverse());
|
.then(data => data.builds.reverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
const benchmarkNames = [
|
|
||||||
"hello",
|
|
||||||
"relative_import",
|
|
||||||
"cold_hello",
|
|
||||||
"cold_relative_import"
|
|
||||||
];
|
|
||||||
export function createExecTimeColumns(data) {
|
export function createExecTimeColumns(data) {
|
||||||
|
const benchmarkNames = Object.keys(data[data.length - 1].benchmark);
|
||||||
return benchmarkNames.map(name => [
|
return benchmarkNames.map(name => [
|
||||||
name,
|
name,
|
||||||
...data.map(d => {
|
...data.map(d => {
|
||||||
|
@ -33,8 +28,9 @@ export function createExecTimeColumns(data) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const binarySizeNames = ["deno", "main.js", "main.js.map", "snapshot_deno.bin"];
|
|
||||||
export function createBinarySizeColumns(data) {
|
export function createBinarySizeColumns(data) {
|
||||||
|
const propName = "binary_size";
|
||||||
|
const binarySizeNames = Object.keys(data[data.length - 1][propName]);
|
||||||
return binarySizeNames.map(name => [
|
return binarySizeNames.map(name => [
|
||||||
name,
|
name,
|
||||||
...data.map(d => {
|
...data.map(d => {
|
||||||
|
@ -52,12 +48,13 @@ export function createBinarySizeColumns(data) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const threadCountNames = ["set_timeout", "fetch_deps"];
|
|
||||||
export function createThreadCountColumns(data) {
|
export function createThreadCountColumns(data) {
|
||||||
|
const propName = "thread_count";
|
||||||
|
const threadCountNames = Object.keys(data[data.length - 1][propName]);
|
||||||
return threadCountNames.map(name => [
|
return threadCountNames.map(name => [
|
||||||
name,
|
name,
|
||||||
...data.map(d => {
|
...data.map(d => {
|
||||||
const threadCountData = d["thread_count"];
|
const threadCountData = d[propName];
|
||||||
if (!threadCountData) {
|
if (!threadCountData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -66,12 +63,13 @@ export function createThreadCountColumns(data) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const syscallCountNames = ["hello", "fetch_deps"];
|
|
||||||
export function createSyscallCountColumns(data) {
|
export function createSyscallCountColumns(data) {
|
||||||
|
const propName = "syscall_count";
|
||||||
|
const syscallCountNames = Object.keys(data[data.length - 1][propName]);
|
||||||
return syscallCountNames.map(name => [
|
return syscallCountNames.map(name => [
|
||||||
name,
|
name,
|
||||||
...data.map(d => {
|
...data.map(d => {
|
||||||
const syscallCountData = d["syscall_count"];
|
const syscallCountData = d[propName];
|
||||||
if (!syscallCountData) {
|
if (!syscallCountData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -80,13 +78,8 @@ export function createSyscallCountColumns(data) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const travisCompileTimeNames = ["duration_time"];
|
|
||||||
function createTravisCompileTimeColumns(data) {
|
function createTravisCompileTimeColumns(data) {
|
||||||
const columnsData = travisCompileTimeNames.map(name => [
|
return [["duration_time", ...data.map(d => d.duration)]];
|
||||||
name,
|
|
||||||
...data.map(d => d.duration)
|
|
||||||
]);
|
|
||||||
return columnsData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSha1List(data) {
|
export function createSha1List(data) {
|
||||||
|
|
|
@ -83,21 +83,31 @@ const irregularData = [
|
||||||
{
|
{
|
||||||
created_at: "2018-01-01T01:00:00Z",
|
created_at: "2018-01-01T01:00:00Z",
|
||||||
sha1: "123",
|
sha1: "123",
|
||||||
|
benchmark: {},
|
||||||
binary_size: {},
|
binary_size: {},
|
||||||
benchmark: {
|
|
||||||
hello: {},
|
|
||||||
relative_import: {},
|
|
||||||
cold_hello: {},
|
|
||||||
cold_relative_import: {}
|
|
||||||
},
|
|
||||||
thread_count: {},
|
thread_count: {},
|
||||||
syscall_count: {}
|
syscall_count: {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
created_at: "2018-02-01T01:00:00Z",
|
created_at: "2018-02-01T01:00:00Z",
|
||||||
sha1: "456",
|
sha1: "456",
|
||||||
binary_size: 100000000,
|
benchmark: {
|
||||||
benchmark: {}
|
hello: {},
|
||||||
|
relative_import: {},
|
||||||
|
cold_hello: {},
|
||||||
|
cold_relative_import: {}
|
||||||
|
},
|
||||||
|
binary_size: {
|
||||||
|
deno: 1
|
||||||
|
},
|
||||||
|
thread_count: {
|
||||||
|
set_timeout: 5,
|
||||||
|
fetch_deps: 7
|
||||||
|
},
|
||||||
|
syscall_count: {
|
||||||
|
hello: 700,
|
||||||
|
fetch_deps: 800
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -133,12 +143,7 @@ test(function createBinarySizeColumnsRegularData() {
|
||||||
|
|
||||||
test(function createBinarySizeColumnsIrregularData() {
|
test(function createBinarySizeColumnsIrregularData() {
|
||||||
const columns = createBinarySizeColumns(irregularData);
|
const columns = createBinarySizeColumns(irregularData);
|
||||||
assertEqual(columns, [
|
assertEqual(columns, [["deno", null, 1]]);
|
||||||
["deno", null, 100000000],
|
|
||||||
["main.js", null, 0],
|
|
||||||
["main.js.map", null, 0],
|
|
||||||
["snapshot_deno.bin", null, 0]
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function createThreadCountColumnsRegularData() {
|
test(function createThreadCountColumnsRegularData() {
|
||||||
|
@ -148,10 +153,7 @@ test(function createThreadCountColumnsRegularData() {
|
||||||
|
|
||||||
test(function createThreadCountColumnsIrregularData() {
|
test(function createThreadCountColumnsIrregularData() {
|
||||||
const columns = createThreadCountColumns(irregularData);
|
const columns = createThreadCountColumns(irregularData);
|
||||||
assertEqual(columns, [
|
assertEqual(columns, [["set_timeout", null, 5], ["fetch_deps", null, 7]]);
|
||||||
["set_timeout", null, null],
|
|
||||||
["fetch_deps", null, null]
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function createSyscallCountColumnsRegularData() {
|
test(function createSyscallCountColumnsRegularData() {
|
||||||
|
@ -161,7 +163,7 @@ test(function createSyscallCountColumnsRegularData() {
|
||||||
|
|
||||||
test(function createSyscallCountColumnsIrregularData() {
|
test(function createSyscallCountColumnsIrregularData() {
|
||||||
const columns = createSyscallCountColumns(irregularData);
|
const columns = createSyscallCountColumns(irregularData);
|
||||||
assertEqual(columns, [["hello", null, null], ["fetch_deps", null, null]]);
|
assertEqual(columns, [["hello", null, 700], ["fetch_deps", null, 800]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function createSha1ListRegularData() {
|
test(function createSha1ListRegularData() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue