2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2019-02-06 18:08:26 -05:00
|
|
|
// How much to multiply time values in order to process log graphs properly.
|
|
|
|
const TimeScaleFactor = 10000;
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export interface BenchmarkExecTimeResult {
|
|
|
|
min?: number;
|
|
|
|
max?: number;
|
|
|
|
mean?: number;
|
|
|
|
stddev?: number;
|
|
|
|
system?: number;
|
|
|
|
user?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BenchmarkExecTimeResultSet {
|
|
|
|
[variant: string]: BenchmarkExecTimeResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BenchmarkVariantsResultSet {
|
|
|
|
[variant: string]: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BenchmarkRun {
|
|
|
|
created_at: string;
|
|
|
|
sha1: string;
|
|
|
|
benchmark: BenchmarkExecTimeResultSet;
|
|
|
|
binary_size?: BenchmarkVariantsResultSet | number;
|
|
|
|
max_memory?: BenchmarkVariantsResultSet | number;
|
|
|
|
bundle_size?: BenchmarkVariantsResultSet;
|
|
|
|
max_latency?: BenchmarkVariantsResultSet;
|
|
|
|
req_per_sec?: BenchmarkVariantsResultSet;
|
|
|
|
req_per_sec_proxy?: BenchmarkVariantsResultSet;
|
|
|
|
syscall_count?: BenchmarkVariantsResultSet;
|
|
|
|
thread_count?: BenchmarkVariantsResultSet;
|
|
|
|
throughput?: BenchmarkVariantsResultSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type BenchmarkName = Exclude<keyof BenchmarkRun, "created_at" | "sha1">;
|
|
|
|
|
|
|
|
type Column = [string, ...Array<number | null>];
|
|
|
|
|
|
|
|
interface C3DataNode {
|
|
|
|
id: string;
|
|
|
|
index: number;
|
|
|
|
name: string;
|
|
|
|
value: number;
|
|
|
|
x: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
type C3OnClickCallback = (C3DataNode, unknown) => void;
|
|
|
|
type C3OnRenderedCallback = () => void;
|
|
|
|
type C3TickFormatter = (number) => number | string;
|
|
|
|
|
|
|
|
export async function getJson(path: string): Promise<unknown> {
|
2018-09-24 11:31:14 -04:00
|
|
|
return (await fetch(path)).json();
|
|
|
|
}
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function getBenchmarkVarieties(
|
|
|
|
data: BenchmarkRun[],
|
|
|
|
benchmarkName: BenchmarkName
|
|
|
|
): string[] {
|
2018-10-11 16:55:22 -04:00
|
|
|
// Look at last sha hash.
|
|
|
|
const last = data[data.length - 1];
|
|
|
|
return Object.keys(last[benchmarkName]);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createColumns(
|
|
|
|
data: BenchmarkRun[],
|
|
|
|
benchmarkName: BenchmarkName
|
|
|
|
): Column[] {
|
2018-10-11 16:55:22 -04:00
|
|
|
const varieties = getBenchmarkVarieties(data, benchmarkName);
|
|
|
|
return varieties.map(variety => [
|
|
|
|
variety,
|
2018-09-21 12:06:59 -04:00
|
|
|
...data.map(d => {
|
2018-10-11 16:55:22 -04:00
|
|
|
if (d[benchmarkName] != null) {
|
|
|
|
if (d[benchmarkName][variety] != null) {
|
|
|
|
const v = d[benchmarkName][variety];
|
|
|
|
if (benchmarkName == "benchmark") {
|
|
|
|
const meanValue = v ? v.mean : 0;
|
|
|
|
return meanValue || null;
|
|
|
|
} else {
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2018-09-21 12:06:59 -04:00
|
|
|
})
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
|
2019-09-11 16:09:58 -04:00
|
|
|
export function createNormalizedColumns(
|
2019-09-16 17:25:32 -04:00
|
|
|
data: BenchmarkRun[],
|
|
|
|
benchmarkName: BenchmarkName,
|
|
|
|
baselineBenchmark: BenchmarkName,
|
|
|
|
baselineVariety: string
|
|
|
|
): Column[] {
|
2019-09-11 16:09:58 -04:00
|
|
|
const varieties = getBenchmarkVarieties(data, benchmarkName);
|
|
|
|
return varieties.map(variety => [
|
|
|
|
variety,
|
|
|
|
...data.map(d => {
|
|
|
|
if (d[baselineBenchmark] != null) {
|
|
|
|
if (d[baselineBenchmark][baselineVariety] != null) {
|
|
|
|
const baseline = d[baselineBenchmark][baselineVariety];
|
|
|
|
if (d[benchmarkName] != null) {
|
|
|
|
if (d[benchmarkName][variety] != null && baseline != 0) {
|
|
|
|
const v = d[benchmarkName][variety];
|
|
|
|
if (benchmarkName == "benchmark") {
|
|
|
|
const meanValue = v ? v.mean : 0;
|
|
|
|
return meanValue || null;
|
|
|
|
} else {
|
|
|
|
return v / baseline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createExecTimeColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-11 16:55:22 -04:00
|
|
|
return createColumns(data, "benchmark");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createThroughputColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-11 16:55:22 -04:00
|
|
|
return createColumns(data, "throughput");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createProxyColumns(data: BenchmarkRun[]): Column[] {
|
2019-06-06 22:46:18 -04:00
|
|
|
return createColumns(data, "req_per_sec_proxy");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createNormalizedProxyColumns(data: BenchmarkRun[]): Column[] {
|
2019-09-11 16:09:58 -04:00
|
|
|
return createNormalizedColumns(
|
|
|
|
data,
|
|
|
|
"req_per_sec_proxy",
|
|
|
|
"req_per_sec",
|
|
|
|
"hyper"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createReqPerSecColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-15 16:44:35 -04:00
|
|
|
return createColumns(data, "req_per_sec");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createNormalizedReqPerSecColumns(
|
|
|
|
data: BenchmarkRun[]
|
|
|
|
): Column[] {
|
2019-09-11 16:09:58 -04:00
|
|
|
return createNormalizedColumns(data, "req_per_sec", "req_per_sec", "hyper");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createMaxLatencyColumns(data: BenchmarkRun[]): Column[] {
|
2019-03-24 23:36:27 -04:00
|
|
|
return createColumns(data, "max_latency");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createMaxMemoryColumns(data: BenchmarkRun[]): Column[] {
|
2019-04-16 13:57:05 -04:00
|
|
|
return createColumns(data, "max_memory");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createBinarySizeColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "binary_size";
|
|
|
|
const binarySizeNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-25 20:08:09 -04:00
|
|
|
return binarySizeNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
|
|
|
const binarySizeData = d["binary_size"];
|
|
|
|
switch (typeof binarySizeData) {
|
|
|
|
case "number": // legacy implementation
|
|
|
|
return name === "deno" ? binarySizeData : 0;
|
|
|
|
default:
|
|
|
|
if (!binarySizeData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-25 20:08:09 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return binarySizeData[name] || null;
|
2018-09-25 20:08:09 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]);
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createThreadCountColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "thread_count";
|
|
|
|
const threadCountNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-24 18:12:52 -04:00
|
|
|
return threadCountNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
2018-10-06 22:21:51 -04:00
|
|
|
const threadCountData = d[propName];
|
2018-09-24 18:12:52 -04:00
|
|
|
if (!threadCountData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-24 18:12:52 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return threadCountData[name] || null;
|
2018-09-24 18:12:52 -04:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createSyscallCountColumns(data: BenchmarkRun[]): Column[] {
|
2018-10-06 22:21:51 -04:00
|
|
|
const propName = "syscall_count";
|
|
|
|
const syscallCountNames = Object.keys(data[data.length - 1][propName]);
|
2018-09-24 23:58:18 -04:00
|
|
|
return syscallCountNames.map(name => [
|
|
|
|
name,
|
|
|
|
...data.map(d => {
|
2018-10-06 22:21:51 -04:00
|
|
|
const syscallCountData = d[propName];
|
2018-09-24 23:58:18 -04:00
|
|
|
if (!syscallCountData) {
|
2018-10-03 05:21:26 -04:00
|
|
|
return null;
|
2018-09-24 23:58:18 -04:00
|
|
|
}
|
2018-10-03 05:21:26 -04:00
|
|
|
return syscallCountData[name] || null;
|
2018-09-24 23:58:18 -04:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createBundleSizeColumns(data: BenchmarkRun[]): Column[] {
|
2019-07-28 06:11:08 -04:00
|
|
|
return createColumns(data, "bundle_size");
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function createSha1List(data: BenchmarkRun[]): string[] {
|
2018-09-24 11:31:14 -04:00
|
|
|
return data.map(d => d.sha1);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function formatKB(bytes: number): string {
|
2019-07-28 06:11:08 -04:00
|
|
|
return (bytes / 1024).toFixed(2);
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function formatMB(bytes: number): string {
|
2019-01-30 14:01:13 -05:00
|
|
|
return (bytes / (1024 * 1024)).toFixed(2);
|
2018-10-24 10:04:33 -04:00
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function formatReqSec(reqPerSec: number): string {
|
|
|
|
return (reqPerSec / 1000).toFixed(3);
|
2018-09-24 11:31:14 -04:00
|
|
|
}
|
2018-09-21 12:06:59 -04:00
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
export function formatPercentage(decimal: number): string {
|
2019-09-11 16:09:58 -04:00
|
|
|
return (decimal * 100).toFixed(2);
|
|
|
|
}
|
|
|
|
|
2018-10-20 03:56:24 -04:00
|
|
|
/**
|
|
|
|
* @param {string} id The id of dom element
|
2018-10-20 12:43:40 -04:00
|
|
|
* @param {string[]} categories categories for x-axis values
|
2018-10-20 03:56:24 -04:00
|
|
|
* @param {any[][]} columns The columns data
|
2018-10-20 12:43:40 -04:00
|
|
|
* @param {function} onclick action on clicking nodes of chart
|
|
|
|
* @param {string} yLabel label of y axis
|
|
|
|
* @param {function} yTickFormat formatter of y axis ticks
|
2019-07-21 18:19:37 -04:00
|
|
|
* @param {boolean} zoomEnabled enables the zoom feature
|
2018-10-20 03:56:24 -04:00
|
|
|
*/
|
2018-10-24 10:04:33 -04:00
|
|
|
function generate(
|
2019-09-16 17:25:32 -04:00
|
|
|
id: string,
|
|
|
|
categories: string[],
|
|
|
|
columns: Column[],
|
|
|
|
onclick: C3OnClickCallback,
|
2018-10-20 12:43:40 -04:00
|
|
|
yLabel = "",
|
2019-09-16 17:25:32 -04:00
|
|
|
yTickFormat?: C3TickFormatter,
|
2019-09-11 16:09:58 -04:00
|
|
|
zoomEnabled = true,
|
2019-09-16 17:25:32 -04:00
|
|
|
onrendered?: C3OnRenderedCallback
|
|
|
|
): void {
|
2018-10-24 10:04:33 -04:00
|
|
|
const yAxis = {
|
|
|
|
padding: { bottom: 0 },
|
2019-02-11 17:41:13 -05:00
|
|
|
min: 0,
|
2019-06-11 14:38:19 -04:00
|
|
|
label: yLabel,
|
|
|
|
tick: null
|
2018-10-20 12:43:40 -04:00
|
|
|
};
|
|
|
|
if (yTickFormat) {
|
2018-10-24 10:04:33 -04:00
|
|
|
yAxis.tick = {
|
2018-10-20 12:43:40 -04:00
|
|
|
format: yTickFormat
|
|
|
|
};
|
2019-02-06 18:08:26 -05:00
|
|
|
if (yTickFormat == logScale) {
|
2019-02-11 17:41:13 -05:00
|
|
|
delete yAxis.min;
|
2019-09-16 17:25:32 -04:00
|
|
|
for (const col of columns) {
|
2019-02-06 18:08:26 -05:00
|
|
|
for (let i = 1; i < col.length; i++) {
|
2019-04-30 13:42:36 -04:00
|
|
|
if (col[i] == null || col[i] === 0) {
|
2019-02-06 18:08:26 -05:00
|
|
|
continue;
|
|
|
|
}
|
2019-09-16 17:25:32 -04:00
|
|
|
col[i] = Math.log10((col[i] as number) * TimeScaleFactor);
|
2019-02-06 18:08:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-20 12:43:40 -04:00
|
|
|
}
|
|
|
|
|
2018-10-24 15:26:21 -04:00
|
|
|
// @ts-ignore
|
2018-10-18 06:23:26 -04:00
|
|
|
c3.generate({
|
|
|
|
bindto: id,
|
2019-09-11 16:09:58 -04:00
|
|
|
onrendered,
|
2018-10-18 06:23:26 -04:00
|
|
|
data: {
|
|
|
|
columns,
|
|
|
|
onclick
|
|
|
|
},
|
|
|
|
axis: {
|
2018-10-24 10:04:33 -04:00
|
|
|
x: {
|
|
|
|
type: "category",
|
|
|
|
show: false,
|
|
|
|
categories
|
|
|
|
},
|
|
|
|
y: yAxis
|
2019-07-21 18:19:37 -04:00
|
|
|
},
|
|
|
|
zoom: {
|
|
|
|
enabled: zoomEnabled
|
2018-10-18 06:23:26 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function logScale(t: number): string {
|
2019-02-06 18:08:26 -05:00
|
|
|
return (Math.pow(10, t) / TimeScaleFactor).toFixed(4);
|
|
|
|
}
|
|
|
|
|
2018-10-20 03:56:24 -04:00
|
|
|
/**
|
2019-06-15 14:22:27 -04:00
|
|
|
* @param dataUrl The url of benchmark data json.
|
2018-10-20 03:56:24 -04:00
|
|
|
*/
|
2019-09-16 17:25:32 -04:00
|
|
|
export function drawCharts(dataUrl: string): Promise<void> {
|
2018-11-14 09:38:42 -05:00
|
|
|
// TODO Using window["location"]["hostname"] instead of
|
|
|
|
// window.location.hostname because when deno runs app_test.js it gets a type
|
|
|
|
// error here, not knowing about window.location. Ideally Deno would skip
|
|
|
|
// type check entirely on JS files.
|
|
|
|
if (window["location"]["hostname"] != "deno.github.io") {
|
|
|
|
dataUrl = "https://denoland.github.io/deno/" + dataUrl;
|
|
|
|
}
|
2019-04-25 13:20:10 -04:00
|
|
|
return drawChartsFromBenchmarkData(dataUrl);
|
2018-10-16 12:00:47 -04:00
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
const proxyFields: BenchmarkName[] = ["req_per_sec"];
|
|
|
|
function extractProxyFields(data: BenchmarkRun[]): void {
|
2019-06-06 22:46:18 -04:00
|
|
|
for (const row of data) {
|
|
|
|
for (const field of proxyFields) {
|
|
|
|
const d = row[field];
|
|
|
|
if (!d) continue;
|
|
|
|
const name = field + "_proxy";
|
|
|
|
const newField = {};
|
|
|
|
row[name] = newField;
|
|
|
|
for (const k of Object.getOwnPropertyNames(d)) {
|
|
|
|
if (k.includes("_proxy")) {
|
|
|
|
const v = d[k];
|
|
|
|
delete d[k];
|
|
|
|
newField[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-16 12:00:47 -04:00
|
|
|
/**
|
|
|
|
* Draws the charts from the benchmark data stored in gh-pages branch.
|
|
|
|
*/
|
2019-09-16 17:25:32 -04:00
|
|
|
export async function drawChartsFromBenchmarkData(
|
|
|
|
dataUrl: string
|
|
|
|
): Promise<void> {
|
|
|
|
const data = (await getJson(dataUrl)) as BenchmarkRun[];
|
2018-09-24 11:31:14 -04:00
|
|
|
|
2019-06-06 22:46:18 -04:00
|
|
|
// hack to extract proxy fields from req/s fields
|
|
|
|
extractProxyFields(data);
|
|
|
|
|
2018-09-24 11:31:14 -04:00
|
|
|
const execTimeColumns = createExecTimeColumns(data);
|
2018-10-11 16:55:22 -04:00
|
|
|
const throughputColumns = createThroughputColumns(data);
|
2018-10-15 16:44:35 -04:00
|
|
|
const reqPerSecColumns = createReqPerSecColumns(data);
|
2019-09-11 16:09:58 -04:00
|
|
|
const normalizedReqPerSecColumns = createNormalizedReqPerSecColumns(data);
|
2019-06-06 22:46:18 -04:00
|
|
|
const proxyColumns = createProxyColumns(data);
|
2019-09-11 16:09:58 -04:00
|
|
|
const normalizedProxyColumns = createNormalizedProxyColumns(data);
|
2019-03-24 23:36:27 -04:00
|
|
|
const maxLatencyColumns = createMaxLatencyColumns(data);
|
2019-04-16 13:57:05 -04:00
|
|
|
const maxMemoryColumns = createMaxMemoryColumns(data);
|
2018-09-24 11:31:14 -04:00
|
|
|
const binarySizeColumns = createBinarySizeColumns(data);
|
2018-09-24 18:12:52 -04:00
|
|
|
const threadCountColumns = createThreadCountColumns(data);
|
2018-09-24 23:58:18 -04:00
|
|
|
const syscallCountColumns = createSyscallCountColumns(data);
|
2019-07-28 06:11:08 -04:00
|
|
|
const bundleSizeColumns = createBundleSizeColumns(data);
|
2018-09-24 11:31:14 -04:00
|
|
|
const sha1List = createSha1List(data);
|
2018-09-26 20:41:23 -04:00
|
|
|
const sha1ShortList = sha1List.map(sha1 => sha1.substring(0, 6));
|
2018-09-27 02:19:42 -04:00
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function viewCommitOnClick(d: C3DataNode, _: unknown): void {
|
2018-10-24 15:26:21 -04:00
|
|
|
// @ts-ignore
|
2019-09-16 17:25:32 -04:00
|
|
|
window.open(`https://github.com/denoland/deno/commit/${sha1List[d.index]}`);
|
|
|
|
}
|
2018-09-27 02:19:42 -04:00
|
|
|
|
2019-09-11 16:09:58 -04:00
|
|
|
function gen(
|
2019-09-16 17:25:32 -04:00
|
|
|
id: string,
|
|
|
|
columns: Column[],
|
2019-09-11 16:09:58 -04:00
|
|
|
yLabel = "",
|
2019-09-16 17:25:32 -04:00
|
|
|
yTickFormat?: C3TickFormatter,
|
|
|
|
onrendered?: C3OnRenderedCallback
|
|
|
|
): void {
|
2018-10-24 10:04:33 -04:00
|
|
|
generate(
|
2018-10-20 12:43:40 -04:00
|
|
|
id,
|
|
|
|
sha1ShortList,
|
|
|
|
columns,
|
2019-09-16 17:25:32 -04:00
|
|
|
viewCommitOnClick,
|
2018-10-20 12:43:40 -04:00
|
|
|
yLabel,
|
2019-09-11 16:09:58 -04:00
|
|
|
yTickFormat,
|
|
|
|
true,
|
|
|
|
onrendered
|
2018-10-20 12:43:40 -04:00
|
|
|
);
|
2018-10-18 06:23:26 -04:00
|
|
|
}
|
2018-09-23 11:54:07 -04:00
|
|
|
|
2019-02-06 18:08:26 -05:00
|
|
|
gen("#exec-time-chart", execTimeColumns, "seconds", logScale);
|
2019-02-11 17:41:13 -05:00
|
|
|
gen("#throughput-chart", throughputColumns, "seconds", logScale);
|
2018-10-24 10:04:33 -04:00
|
|
|
gen("#req-per-sec-chart", reqPerSecColumns, "1000 req/sec", formatReqSec);
|
2019-09-11 16:09:58 -04:00
|
|
|
gen(
|
|
|
|
"#normalized-req-per-sec-chart",
|
|
|
|
normalizedReqPerSecColumns,
|
|
|
|
"% of hyper througput",
|
|
|
|
formatPercentage,
|
|
|
|
hideOnRender("normalized-req-per-sec-chart")
|
|
|
|
);
|
2019-06-06 22:46:18 -04:00
|
|
|
gen("#proxy-req-per-sec-chart", proxyColumns, "req/sec");
|
2019-09-11 16:09:58 -04:00
|
|
|
gen(
|
|
|
|
"#normalized-proxy-req-per-sec-chart",
|
|
|
|
normalizedProxyColumns,
|
|
|
|
"% of hyper througput",
|
|
|
|
formatPercentage,
|
|
|
|
hideOnRender("normalized-proxy-req-per-sec-chart")
|
|
|
|
);
|
2019-03-24 23:36:27 -04:00
|
|
|
gen("#max-latency-chart", maxLatencyColumns, "milliseconds", logScale);
|
2019-04-16 13:57:05 -04:00
|
|
|
gen("#max-memory-chart", maxMemoryColumns, "megabytes", formatMB);
|
2018-10-24 10:04:33 -04:00
|
|
|
gen("#binary-size-chart", binarySizeColumns, "megabytes", formatMB);
|
|
|
|
gen("#thread-count-chart", threadCountColumns, "threads");
|
|
|
|
gen("#syscall-count-chart", syscallCountColumns, "syscalls");
|
2019-07-28 06:11:08 -04:00
|
|
|
gen("#bundle-size-chart", bundleSizeColumns, "kilobytes", formatKB);
|
2018-10-16 12:00:47 -04:00
|
|
|
}
|
2019-06-11 14:38:19 -04:00
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function hideOnRender(elementID: string): C3OnRenderedCallback {
|
|
|
|
return (): void => {
|
2019-09-11 16:09:58 -04:00
|
|
|
const chart = window["document"].getElementById(elementID);
|
|
|
|
if (!chart.getAttribute("data-inital-hide-done")) {
|
|
|
|
chart.setAttribute("data-inital-hide-done", "true");
|
|
|
|
chart.classList.add("hidden");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function registerNormalizedSwitcher(
|
|
|
|
checkboxID: string,
|
|
|
|
chartID: string,
|
|
|
|
normalizedChartID: string
|
|
|
|
): void {
|
2019-09-11 16:09:58 -04:00
|
|
|
const checkbox = window["document"].getElementById(checkboxID);
|
|
|
|
const regularChart = window["document"].getElementById(chartID);
|
|
|
|
const normalizedChart = window["document"].getElementById(normalizedChartID);
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
checkbox.addEventListener("change", _ => {
|
2019-09-11 16:09:58 -04:00
|
|
|
// If checked is true the normalized variant should be shown
|
|
|
|
// @ts-ignore
|
|
|
|
if (checkbox.checked) {
|
|
|
|
regularChart.classList.add("hidden");
|
|
|
|
normalizedChart.classList.remove("hidden");
|
|
|
|
} else {
|
|
|
|
normalizedChart.classList.add("hidden");
|
|
|
|
regularChart.classList.remove("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-11 14:38:19 -04:00
|
|
|
export function main(): void {
|
|
|
|
window["chartWidth"] = 800;
|
|
|
|
const overlay = window["document"].getElementById("spinner-overlay");
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function showSpinner(): void {
|
2019-06-11 14:38:19 -04:00
|
|
|
overlay.style.display = "block";
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function hideSpinner(): void {
|
2019-06-11 14:38:19 -04:00
|
|
|
overlay.style.display = "none";
|
|
|
|
}
|
|
|
|
|
2019-09-16 17:25:32 -04:00
|
|
|
function updateCharts(): void {
|
2019-06-11 14:38:19 -04:00
|
|
|
const u = window.location.hash.match("all") ? "./data.json" : "recent.json";
|
|
|
|
|
|
|
|
showSpinner();
|
|
|
|
|
2019-06-15 14:22:27 -04:00
|
|
|
drawCharts(u)
|
|
|
|
.then(hideSpinner)
|
|
|
|
.catch(hideSpinner);
|
2019-06-11 14:38:19 -04:00
|
|
|
}
|
|
|
|
updateCharts();
|
|
|
|
|
2019-09-11 16:09:58 -04:00
|
|
|
registerNormalizedSwitcher(
|
|
|
|
"req-per-sec-chart-show-normalized",
|
|
|
|
"req-per-sec-chart",
|
|
|
|
"normalized-req-per-sec-chart"
|
|
|
|
);
|
|
|
|
|
|
|
|
registerNormalizedSwitcher(
|
|
|
|
"proxy-req-per-sec-chart-show-normalized",
|
|
|
|
"proxy-req-per-sec-chart",
|
|
|
|
"normalized-proxy-req-per-sec-chart"
|
|
|
|
);
|
|
|
|
|
2019-06-11 14:38:19 -04:00
|
|
|
window["onhashchange"] = updateCharts;
|
|
|
|
}
|