mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
benchmark: track the binary size (#804)
This commit is contained in:
parent
56acb6fa0e
commit
9203e983d1
4 changed files with 59 additions and 4 deletions
|
@ -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"]):
|
||||
|
|
23
website/README.md
Normal file
23
website/README.md
Normal file
|
@ -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
|
||||
}
|
||||
}
|
||||
```
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue