Skip to content

Commit

Permalink
Use 'deno bundle' for benchmark page
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 9, 2019
1 parent b205ebc commit 6e5f5b7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 15,5 @@ node_modules
# temp benchmark data
/website/data.json
/website/recent.json
/website/*.bundle.js
/js/gen
2 changes: 1 addition & 1 deletion js/unit_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 50,7 @@ import "./performance_test.ts";
import "./permissions_test.ts";
import "./version_test.ts";

import "../website/app_test.js";
import "../website/app_test.ts";

import { runIfMain } from "./deps/https/deno.land/std/testing/mod.ts";

Expand Down
8 changes: 8 additions & 0 deletions tools/build_website.py
Original file line number Diff line number Diff line change
@@ -0,0 1,8 @@
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import os
from util import run, root_path, build_path

os.chdir(os.path.join(root_path, "website"))
deno_exe = os.path.join(build_path(), "deno")
run([deno_exe, "bundle", "app.ts", "app.bundle.js"])
6 changes: 5 additions & 1 deletion tools/upload_website.py
Original file line number Diff line number Diff line change
@@ -1,14 1,18 @@
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import os
import sys
import tempfile
from util import run, root_path
from util import run, root_path, build_path

# Probably run tools/docs.py first.
# AWS CLI must be installed separately.

os.chdir(os.path.join(root_path, "website"))

deno_exe = os.path.join(build_path(), "deno")
run([sys.executable, "../tools/build_website.py"])

# Invalidate the cache.
run([
"aws", "cloudfront", "create-invalidation", "--distribution-id",
Expand Down
27 changes: 26 additions & 1 deletion website/app.js → website/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 139,8 @@ function generate(
const yAxis = {
padding: { bottom: 0 },
min: 0,
label: yLabel
label: yLabel,
tick: null
};
if (yTickFormat) {
yAxis.tick = {
Expand Down Expand Up @@ -272,3 273,27 @@ export async function drawChartsFromBenchmarkData(dataUrl) {
gen("#thread-count-chart", threadCountColumns, "threads");
gen("#syscall-count-chart", syscallCountColumns, "syscalls");
}

export function main(): void {
window["chartWidth"] = 800;
const overlay = window["document"].getElementById("spinner-overlay");

function showSpinner() {
overlay.style.display = "block";
}

function hideSpinner() {
overlay.style.display = "none";
}

function updateCharts() {
const u = window.location.hash.match("all") ? "./data.json" : "recent.json";

showSpinner();

drawCharts(u).finally(hideSpinner);
}
updateCharts();

window["onhashchange"] = updateCharts;
}
5 changes: 4 additions & 1 deletion website/app_test.js → website/app_test.ts
Original file line number Diff line number Diff line change
@@ -1,13 1,14 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.

import { test, testPerm, assert, assertEquals } from "../js/test_util.ts";
import { runIfMain } from "../js/deps/https/deno.land/std/testing/mod.ts";
import {
createBinarySizeColumns,
createExecTimeColumns,
createThreadCountColumns,
createSyscallCountColumns,
createSha1List
} from "./app.js";
} from "./app.ts";

const regularData = [
{
Expand Down Expand Up @@ -191,3 192,5 @@ test(function createSha1ListRegularData() {
const sha1List = createSha1List(regularData);
assertEquals(sha1List, ["abcdef", "012345"]);
});

runIfMain(import.meta);
33 changes: 8 additions & 25 deletions website/benchmarks.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,31 230,14 @@ <h3 id="syscalls">Syscall count <a href="#syscalls">#</a></h3>
<script src="https://unpkg.com/[email protected]/dist/d3.min.js"></script>
<script src="https://unpkg.com/[email protected]/c3.min.js"></script>

<script type="module">
import { drawCharts } from "./app.js";
window.chartWidth = 800;
const overlay = document.getElementById("spinner-overlay");

function showSpinner() {
overlay.style.display = "block";
}

function hideSpinner() {
overlay.style.display = "none";
}

function updateCharts() {
const u = window.location.hash.match("all")
? "./data.json"
: "recent.json";

showSpinner();

drawCharts(u).finally(hideSpinner);
}
updateCharts();

window.onhashchange = updateCharts;
<!-- Run "deno bundle app.ts" to generate app.bundle.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
<script src="app.bundle.js">
</script>
<script>
requirejs(['app'], function(app) {
app.main()
});
</script>
</body>
</html>

0 comments on commit 6e5f5b7

Please sign in to comment.