summaryrefslogtreecommitdiff
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
parent56acb6fa0e70206738259b80d054931e57617d90 (diff)
benchmark: track the binary size (#804)
-rwxr-xr-xtools/benchmark.py1
-rw-r--r--website/README.md23
-rw-r--r--website/app.js34
-rw-r--r--website/index.html5
4 files changed, 59 insertions, 4 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py
index f0f9e4ac6..d9decefbb 100755
--- a/tools/benchmark.py
+++ b/tools/benchmark.py
@@ -66,6 +66,7 @@ def main(argv):
new_data = {
"created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
"sha1": sha1,
+ "binary_size": os.path.getsize(deno_path),
"benchmark": {}
}
for [[name, _], data] in zip(benchmarks, benchmark_data["results"]):
diff --git a/website/README.md b/website/README.md
new file mode 100644
index 000000000..dece0c7ff
--- /dev/null
+++ b/website/README.md
@@ -0,0 +1,23 @@
+## About benchmark data
+
+The benchmark chart supposes `//website/data.json` has the signature of `BenchmarkData[]` where `BenchmarkData` is defined like the below:
+
+```typescript
+interface ExecTimeData {
+ mean: number
+ stddev: number
+ user: number
+ system: number
+ min: number
+ max: number
+}
+
+interface BenchmarkData {
+ created_at: string,
+ sha1: string,
+ binary_size?: number,
+ benchmark: {
+ [key: string]: ExecTimeData
+ }
+}
+```
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];
+}
diff --git a/website/index.html b/website/index.html
index b15a9c949..7cb8b0298 100644
--- a/website/index.html
+++ b/website/index.html
@@ -5,7 +5,10 @@
<link rel="stylesheet" href="https://unpkg.com/c3@0.6.7/c3.min.css">
</head>
<body>
- <div id="benchmark-chart"></div>
+ <h2>Execution time chart</h2>
+ <div id="exec-time-chart"></div>
+ <h2>Binary size chart</h2>
+ <div id="binary-size-chart"></div>
<script src="https://unpkg.com/d3@5.7.0/dist/d3.min.js"></script>
<script src="https://unpkg.com/c3@0.6.7/c3.min.js"></script>
<script src="./app.js"></script>