summaryrefslogtreecommitdiff
path: root/website/app.js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2018-09-24 00:54:07 +0900
committerRyan Dahl <ry@tinyclouds.org>2018-09-23 11:54:07 -0400
commit9203e983d1536618fb07b3ffd95da177c9bbfdfc (patch)
treecb278c20cfbc9b79af5daca3b89d6aead706430f /website/app.js
parent56acb6fa0e70206738259b80d054931e57617d90 (diff)
benchmark: track the binary size (#804)
Diffstat (limited to 'website/app.js')
-rw-r--r--website/app.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/website/app.js b/website/app.js
index 7a6566a61..66151b6ca 100644
--- a/website/app.js
+++ b/website/app.js
@@ -3,7 +3,7 @@ const benchmarkNames = ["hello", "relative_import"];
(async () => {
const data = await (await fetch("./data.json")).json();
- const benchmarkColumns = benchmarkNames.map(name => [
+ const execTimeColumns = benchmarkNames.map(name => [
name,
...data.map(d => {
const benchmark = d.benchmark[name];
@@ -11,11 +11,12 @@ const benchmarkNames = ["hello", "relative_import"];
})
]);
+ const binarySizeList = data.map(d => d.binary_size || 0);
const sha1List = data.map(d => d.sha1);
c3.generate({
- bindto: "#benchmark-chart",
- data: { columns: benchmarkColumns },
+ bindto: "#exec-time-chart",
+ data: { columns: execTimeColumns },
axis: {
x: {
type: "category",
@@ -23,4 +24,31 @@ const benchmarkNames = ["hello", "relative_import"];
}
}
});
+
+ c3.generate({
+ bindto: "#binary-size-chart",
+ data: { columns: [["binary_size", ...binarySizeList]] },
+ axis: {
+ x: {
+ type: "category",
+ categories: sha1List
+ },
+ y: {
+ tick: {
+ format: d => formatBytes(d)
+ }
+ }
+ }
+ });
})();
+
+// Formats the byte sizes e.g. 19000 -> 18.55KB
+// Copied from https://stackoverflow.com/a/18650828
+function formatBytes(a, b) {
+ if (0 == a) return "0 Bytes";
+ var c = 1024,
+ d = b || 2,
+ e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
+ f = Math.floor(Math.log(a) / Math.log(c));
+ return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
+}