From 1729bdb0d7f504436cacc07bedba642591fdb0cb Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Mon, 24 Sep 2018 18:12:52 -0400 Subject: Add thread count benchmark (#811) --- website/app.js | 26 ++++++++++++++++++++++++++ website/app_test.js | 22 ++++++++++++++++++++-- website/index.html | 2 ++ 3 files changed, 48 insertions(+), 2 deletions(-) (limited to 'website') diff --git a/website/app.js b/website/app.js index 612cc7af0..27baa1958 100644 --- a/website/app.js +++ b/website/app.js @@ -20,6 +20,20 @@ export function createBinarySizeColumns(data) { return [["binary_size", ...data.map(d => d.binary_size || 0)]]; } +const threadCountNames = ["set_timeout"]; +export function createThreadCountColumns(data) { + return threadCountNames.map(name => [ + name, + ...data.map(d => { + const threadCountData = d["thread_count"]; + if (!threadCountData) { + return 0; + } + return threadCountData[name] || 0; + }) + ]); +} + export function createSha1List(data) { return data.map(d => d.sha1); } @@ -40,6 +54,7 @@ export async function main() { const execTimeColumns = createExecTimeColumns(data); const binarySizeColumns = createBinarySizeColumns(data); + const threadCountColumns = createThreadCountColumns(data); const sha1List = createSha1List(data); c3.generate({ @@ -68,4 +83,15 @@ export async function main() { } } }); + + c3.generate({ + bindto: "#thread-count-chart", + data: { columns: threadCountColumns }, + axis: { + x: { + type: "category", + categories: sha1List + } + } + }); } diff --git a/website/app_test.js b/website/app_test.js index 74ccb406d..5fca1e44c 100644 --- a/website/app_test.js +++ b/website/app_test.js @@ -1,9 +1,10 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assertEqual } from "../js/test_util.ts"; +import { test, assertEqual } from "../js/test_util.ts"; import { createBinarySizeColumns, createExecTimeColumns, + createThreadCountColumns, createSha1List, formatBytes } from "./app.js"; @@ -20,6 +21,9 @@ const regularData = [ relative_import: { mean: 0.06 } + }, + thread_count: { + set_timeout: 4 } }, { @@ -33,6 +37,9 @@ const regularData = [ relative_import: { mean: 0.065 } + }, + thread_count: { + set_timeout: 5 } } ]; @@ -44,7 +51,8 @@ const irregularData = [ benchmark: { hello: {}, relative_import: {} - } + }, + thread_count: {} }, { created_at: "2018-02-01T01:00:00Z", @@ -76,6 +84,16 @@ test(function createBinarySizeColumnsIrregularData() { assertEqual(columns, [["binary_size", 0, 0]]); }); +test(function createThreadCountColumnsRegularData() { + const columns = createThreadCountColumns(regularData); + assertEqual(columns, [["set_timeout", 4, 5]]); +}); + +test(function createThreadCountColumnsIrregularData() { + const columns = createThreadCountColumns(irregularData); + assertEqual(columns, [["set_timeout", 0, 0]]); +}); + test(function createSha1ListRegularData() { const sha1List = createSha1List(regularData); assertEqual(sha1List, ["abcdef", "012345"]); diff --git a/website/index.html b/website/index.html index 6ee68af2f..96d1afd7f 100644 --- a/website/index.html +++ b/website/index.html @@ -9,6 +9,8 @@

Binary size chart

+

Thread count chart

+