2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-09-24 11:31:14 -04:00
|
|
|
|
2019-10-04 20:28:51 -04:00
|
|
|
import { test, assertEquals } from "../cli/js/test_util.ts";
|
2019-10-04 14:49:32 -04:00
|
|
|
import { runIfMain } from "../std/testing/mod.ts";
|
2018-09-24 11:31:14 -04:00
|
|
|
import {
|
2019-09-16 17:25:32 -04:00
|
|
|
BenchmarkRun,
|
2018-09-24 11:31:14 -04:00
|
|
|
createBinarySizeColumns,
|
|
|
|
createExecTimeColumns,
|
2018-09-24 18:12:52 -04:00
|
|
|
createThreadCountColumns,
|
2018-09-24 23:58:18 -04:00
|
|
|
createSyscallCountColumns,
|
2019-01-30 13:28:55 -05:00
|
|
|
createSha1List
|
2019-06-11 14:38:19 -04:00
|
|
|
} from "./app.ts";
|
2018-09-24 11:31:14 -04:00
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
/* eslint-disable @typescript-eslint/camelcase */
|
|
|
|
const regularData: BenchmarkRun[] = [
|
2018-09-24 11:31:14 -04:00
|
|
|
{
|
|
|
|
created_at: "2018-01-01T01:00:00Z",
|
|
|
|
sha1: "abcdef",
|
2018-09-25 20:08:09 -04:00
|
|
|
binary_size: {
|
|
|
|
deno: 100000000,
|
|
|
|
"main.js": 90000000,
|
|
|
|
"main.js.map": 80000000,
|
|
|
|
"snapshot_deno.bin": 70000000
|
|
|
|
},
|
2018-10-11 16:55:22 -04:00
|
|
|
throughput: {
|
|
|
|
"100M_tcp": 3.6,
|
|
|
|
"100M_cat": 3.0,
|
|
|
|
"10M_tcp": 1.6,
|
|
|
|
"10M_cat": 1.0
|
|
|
|
},
|
2018-10-15 16:44:35 -04:00
|
|
|
req_per_sec: {
|
|
|
|
node: 16000,
|
|
|
|
deno: 1000
|
|
|
|
},
|
2018-09-24 11:31:14 -04:00
|
|
|
benchmark: {
|
|
|
|
hello: {
|
|
|
|
mean: 0.05
|
|
|
|
},
|
|
|
|
relative_import: {
|
|
|
|
mean: 0.06
|
2018-09-25 04:28:56 -04:00
|
|
|
},
|
|
|
|
cold_hello: {
|
|
|
|
mean: 0.05
|
|
|
|
},
|
|
|
|
cold_relative_import: {
|
|
|
|
mean: 0.06
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
2018-09-24 18:12:52 -04:00
|
|
|
},
|
|
|
|
thread_count: {
|
2018-09-24 23:58:18 -04:00
|
|
|
set_timeout: 4,
|
|
|
|
fetch_deps: 6
|
|
|
|
},
|
|
|
|
syscall_count: {
|
2018-10-03 10:44:21 -04:00
|
|
|
hello: 600,
|
|
|
|
fetch_deps: 700
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
created_at: "2018-01-02T01:00:00Z",
|
|
|
|
sha1: "012345",
|
2018-09-25 20:08:09 -04:00
|
|
|
binary_size: {
|
|
|
|
deno: 100000001,
|
|
|
|
"main.js": 90000001,
|
|
|
|
"main.js.map": 80000001,
|
|
|
|
"snapshot_deno.bin": 70000001
|
|
|
|
},
|
2018-10-11 16:55:22 -04:00
|
|
|
throughput: {
|
|
|
|
"100M_tcp": 3.6,
|
|
|
|
"100M_cat": 3.0,
|
|
|
|
"10M_tcp": 1.6,
|
|
|
|
"10M_cat": 1.0
|
|
|
|
},
|
2018-10-15 16:44:35 -04:00
|
|
|
req_per_sec: {
|
|
|
|
node: 1600,
|
|
|
|
deno: 3.0
|
|
|
|
},
|
2018-09-24 11:31:14 -04:00
|
|
|
benchmark: {
|
|
|
|
hello: {
|
|
|
|
mean: 0.055
|
|
|
|
},
|
|
|
|
relative_import: {
|
|
|
|
mean: 0.065
|
2018-09-25 04:28:56 -04:00
|
|
|
},
|
|
|
|
cold_hello: {
|
|
|
|
mean: 0.055
|
|
|
|
},
|
|
|
|
cold_relative_import: {
|
|
|
|
mean: 0.065
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
2018-09-24 18:12:52 -04:00
|
|
|
},
|
|
|
|
thread_count: {
|
2018-09-24 23:58:18 -04:00
|
|
|
set_timeout: 5,
|
|
|
|
fetch_deps: 7
|
|
|
|
},
|
|
|
|
syscall_count: {
|
2018-10-03 10:44:21 -04:00
|
|
|
hello: 700,
|
|
|
|
fetch_deps: 800
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
const irregularData: BenchmarkRun[] = [
|
2018-09-24 11:31:14 -04:00
|
|
|
{
|
|
|
|
created_at: "2018-01-01T01:00:00Z",
|
|
|
|
sha1: "123",
|
2018-10-06 22:21:51 -04:00
|
|
|
benchmark: {},
|
2018-10-11 16:55:22 -04:00
|
|
|
throughput: {},
|
2018-09-25 20:08:09 -04:00
|
|
|
binary_size: {},
|
2018-09-24 23:58:18 -04:00
|
|
|
thread_count: {},
|
|
|
|
syscall_count: {}
|
2018-09-24 11:31:14 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
created_at: "2018-02-01T01:00:00Z",
|
|
|
|
sha1: "456",
|
2018-10-06 22:21:51 -04:00
|
|
|
benchmark: {
|
|
|
|
hello: {},
|
|
|
|
relative_import: {},
|
|
|
|
cold_hello: {},
|
|
|
|
cold_relative_import: {}
|
|
|
|
},
|
2018-10-11 16:55:22 -04:00
|
|
|
throughput: {
|
|
|
|
"100M_tcp": 3.0
|
|
|
|
},
|
2018-10-06 22:21:51 -04:00
|
|
|
binary_size: {
|
|
|
|
deno: 1
|
|
|
|
},
|
|
|
|
thread_count: {
|
|
|
|
set_timeout: 5,
|
|
|
|
fetch_deps: 7
|
|
|
|
},
|
|
|
|
syscall_count: {
|
|
|
|
hello: 700,
|
|
|
|
fetch_deps: 800
|
|
|
|
}
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
];
|
2019-09-16 17:25:32 -04:00
|
|
|
/* eslint-enable @typescript-eslint/camelcase */
|
2018-09-24 11:31:14 -04:00
|
|
|
|
|
|
|
test(function createExecTimeColumnsRegularData() {
|
|
|
|
const columns = createExecTimeColumns(regularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [
|
2018-09-24 11:31:14 -04:00
|
|
|
["hello", 0.05, 0.055],
|
2018-09-25 04:28:56 -04:00
|
|
|
["relative_import", 0.06, 0.065],
|
|
|
|
["cold_hello", 0.05, 0.055],
|
|
|
|
["cold_relative_import", 0.06, 0.065]
|
2018-09-24 11:31:14 -04:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(function createExecTimeColumnsIrregularData() {
|
|
|
|
const columns = createExecTimeColumns(irregularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [
|
2018-10-03 10:44:21 -04:00
|
|
|
["hello", null, null],
|
|
|
|
["relative_import", null, null],
|
|
|
|
["cold_hello", null, null],
|
|
|
|
["cold_relative_import", null, null]
|
2018-09-25 04:28:56 -04:00
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createBinarySizeColumnsRegularData() {
|
|
|
|
const columns = createBinarySizeColumns(regularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [
|
2018-09-25 20:08:09 -04:00
|
|
|
["deno", 100000000, 100000001],
|
|
|
|
["main.js", 90000000, 90000001],
|
|
|
|
["main.js.map", 80000000, 80000001],
|
|
|
|
["snapshot_deno.bin", 70000000, 70000001]
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createBinarySizeColumnsIrregularData() {
|
|
|
|
const columns = createBinarySizeColumns(irregularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [["deno", null, 1]]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
2018-09-24 18:12:52 -04:00
|
|
|
test(function createThreadCountColumnsRegularData() {
|
|
|
|
const columns = createThreadCountColumns(regularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [["set_timeout", 4, 5], ["fetch_deps", 6, 7]]);
|
2018-09-24 18:12:52 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createThreadCountColumnsIrregularData() {
|
|
|
|
const columns = createThreadCountColumns(irregularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [["set_timeout", null, 5], ["fetch_deps", null, 7]]);
|
2018-09-24 23:58:18 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createSyscallCountColumnsRegularData() {
|
|
|
|
const columns = createSyscallCountColumns(regularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [["hello", 600, 700], ["fetch_deps", 700, 800]]);
|
2018-09-24 23:58:18 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createSyscallCountColumnsIrregularData() {
|
|
|
|
const columns = createSyscallCountColumns(irregularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(columns, [["hello", null, 700], ["fetch_deps", null, 800]]);
|
2018-09-24 18:12:52 -04:00
|
|
|
});
|
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
test(function createSha1ListRegularData() {
|
|
|
|
const sha1List = createSha1List(regularData);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(sha1List, ["abcdef", "012345"]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
2019-06-11 14:38:19 -04:00
|
|
|
|
|
|
|
runIfMain(import.meta);
|