2018-09-24 11:31:14 -04:00
|
|
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2018-09-24 18:12:52 -04:00
|
|
|
import { test, assertEqual } from "../js/test_util.ts";
|
2018-09-24 11:31:14 -04:00
|
|
|
import {
|
|
|
|
createBinarySizeColumns,
|
|
|
|
createExecTimeColumns,
|
2018-09-24 18:12:52 -04:00
|
|
|
createThreadCountColumns,
|
2018-09-24 23:58:18 -04:00
|
|
|
createSyscallCountColumns,
|
2018-09-24 11:31:14 -04:00
|
|
|
createSha1List,
|
|
|
|
formatBytes
|
|
|
|
} from "./app.js";
|
|
|
|
|
|
|
|
const regularData = [
|
|
|
|
{
|
|
|
|
created_at: "2018-01-01T01:00:00Z",
|
|
|
|
sha1: "abcdef",
|
2018-09-26 02:52:47 -04:00
|
|
|
binary_size: 100000000,
|
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: {
|
|
|
|
hello: 600
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
created_at: "2018-01-02T01:00:00Z",
|
|
|
|
sha1: "012345",
|
2018-09-26 02:52:47 -04:00
|
|
|
binary_size: 110000000,
|
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: {
|
|
|
|
hello: 700
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const irregularData = [
|
|
|
|
{
|
|
|
|
created_at: "2018-01-01T01:00:00Z",
|
|
|
|
sha1: "123",
|
|
|
|
benchmark: {
|
|
|
|
hello: {},
|
2018-09-25 04:28:56 -04:00
|
|
|
relative_import: {},
|
|
|
|
cold_hello: {},
|
|
|
|
cold_relative_import: {}
|
2018-09-24 18:12:52 -04:00
|
|
|
},
|
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",
|
|
|
|
benchmark: {}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
test(function createExecTimeColumnsRegularData() {
|
|
|
|
const columns = createExecTimeColumns(regularData);
|
|
|
|
assertEqual(columns, [
|
|
|
|
["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);
|
2018-09-25 04:28:56 -04:00
|
|
|
assertEqual(columns, [
|
|
|
|
["hello", 0, 0],
|
|
|
|
["relative_import", 0, 0],
|
|
|
|
["cold_hello", 0, 0],
|
|
|
|
["cold_relative_import", 0, 0]
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createBinarySizeColumnsRegularData() {
|
|
|
|
const columns = createBinarySizeColumns(regularData);
|
2018-09-26 02:52:47 -04:00
|
|
|
assertEqual(columns, [["binary_size", 100000000, 110000000]]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createBinarySizeColumnsIrregularData() {
|
|
|
|
const columns = createBinarySizeColumns(irregularData);
|
2018-09-26 02:52:47 -04:00
|
|
|
assertEqual(columns, [["binary_size", 0, 0]]);
|
2018-09-24 11:31:14 -04:00
|
|
|
});
|
|
|
|
|
2018-09-24 18:12:52 -04:00
|
|
|
test(function createThreadCountColumnsRegularData() {
|
|
|
|
const columns = createThreadCountColumns(regularData);
|
2018-09-24 23:58:18 -04:00
|
|
|
assertEqual(columns, [["set_timeout", 4, 5], ["fetch_deps", 6, 7]]);
|
2018-09-24 18:12:52 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test(function createThreadCountColumnsIrregularData() {
|
|
|
|
const columns = createThreadCountColumns(irregularData);
|
2018-09-24 23:58:18 -04:00
|
|
|
assertEqual(columns, [["set_timeout", 0, 0], ["fetch_deps", 0, 0]]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(function createSyscallCountColumnsRegularData() {
|
|
|
|
const columns = createSyscallCountColumns(regularData);
|
|
|
|
assertEqual(columns, [["hello", 600, 700]]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(function createSyscallCountColumnsIrregularData() {
|
|
|
|
const columns = createSyscallCountColumns(irregularData);
|
|
|
|
assertEqual(columns, [["hello", 0, 0]]);
|
2018-09-24 18:12:52 -04:00
|
|
|
});
|
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
test(function createSha1ListRegularData() {
|
|
|
|
const sha1List = createSha1List(regularData);
|
|
|
|
assertEqual(sha1List, ["abcdef", "012345"]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(function formatBytesPatterns() {
|
|
|
|
assertEqual(formatBytes(18000), "17.58 KB");
|
|
|
|
assertEqual(formatBytes(1800000), "1.72 MB");
|
|
|
|
assertEqual(formatBytes(180000000), "171.66 MB");
|
|
|
|
assertEqual(formatBytes(18000000000), "16.76 GB");
|
|
|
|
});
|