1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

Add log-scale to execution graph (#1694)

This commit is contained in:
Kaley Main 2019-02-07 10:08:26 +11:00 committed by Ryan Dahl
parent 2782d03b29
commit 39429a261d

View file

@ -1,5 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// How much to multiply time values in order to process log graphs properly.
const TimeScaleFactor = 10000;
export async function getJson(path) { export async function getJson(path) {
return (await fetch(path)).json(); return (await fetch(path)).json();
} }
@ -123,13 +126,22 @@ function generate(
) { ) {
const yAxis = { const yAxis = {
padding: { bottom: 0 }, padding: { bottom: 0 },
min: 0,
label: yLabel label: yLabel
}; };
if (yTickFormat) { if (yTickFormat) {
yAxis.tick = { yAxis.tick = {
format: yTickFormat format: yTickFormat
}; };
if (yTickFormat == logScale) {
for (let col of columns) {
for (let i = 1; i < col.length; i++) {
if (col[i] == null) {
continue;
}
col[i] = Math.log10(col[i] * TimeScaleFactor);
}
}
}
} }
// @ts-ignore // @ts-ignore
@ -150,6 +162,10 @@ function generate(
}); });
} }
function logScale(t) {
return (Math.pow(10, t) / TimeScaleFactor).toFixed(4);
}
function formatSecsAsMins(t) { function formatSecsAsMins(t) {
// TODO use d3.round() // TODO use d3.round()
const a = t % 60; const a = t % 60;
@ -204,7 +220,7 @@ export async function drawChartsFromBenchmarkData(dataUrl) {
); );
} }
gen("#exec-time-chart", execTimeColumns, "seconds"); gen("#exec-time-chart", execTimeColumns, "seconds", logScale);
gen("#throughput-chart", throughputColumns, "seconds"); gen("#throughput-chart", throughputColumns, "seconds");
gen("#req-per-sec-chart", reqPerSecColumns, "1000 req/sec", formatReqSec); gen("#req-per-sec-chart", reqPerSecColumns, "1000 req/sec", formatReqSec);
gen("#binary-size-chart", binarySizeColumns, "megabytes", formatMB); gen("#binary-size-chart", binarySizeColumns, "megabytes", formatMB);