Skip to content

Commit

Permalink
Merge pull request #350 from jpmorganchase/new-benchmarks
Browse files Browse the repository at this point in the history
New benchmarks
  • Loading branch information
texodus authored Dec 20, 2018
2 parents ee0c23d + 2a9d084 commit 794bbbb
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 10,526 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
"build,bench": "npm run --silent build && npm run --silent bench",
"build": "bash -c '[[ -z \"${PSP_DOCKER}\" ]] && npm run --silent _build || npm run --silent _emsdk -- npm run --silent _build'",
"build_cpp": "lerna run build:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
"bench:build": "lerna run bench:build ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream",
"bench:run": "lerna exec ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} -- npm run bench:run",
"bench": "npm-run-all --silent bench:build bench:run",
"bench": "node scripts/bench.js",
"docs": "lerna run docs --silent --stream",
"test": "node scripts/test.js",
"test_cpp": "lerna run test:cpp ${PACKAGE:+--scope=@jpmorganchase/perspective} --stream",
Expand Down
1 change: 1 addition & 0 deletions packages/perspective-viewer/src/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class PerspectiveViewer extends ActionElement {
await this._debounce_update();
}
this.dispatchEvent(new Event("perspective-config-update"));
this.dispatchEvent(new Event("perspective-computed-column-update"));
})();
}

Expand Down
28 changes: 15 additions & 13 deletions packages/perspective-viewer/src/js/viewer/action_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@ export class ActionElement extends DomElement {
this.shadowRoot.querySelector("#app").classList.remove("show_menu");
}

_toggle_config() {
if (this._show_config) {
this._side_panel.style.display = "none";
this._top_panel.style.display = "none";
this.removeAttribute("settings");
} else {
this._side_panel.style.display = "flex";
this._top_panel.style.display = "flex";
this.setAttribute("settings", true);
_toggle_config(event) {
if (!event || event.button !== 2) {
if (this._show_config) {
this._side_panel.style.display = "none";
this._top_panel.style.display = "none";
this.removeAttribute("settings");
} else {
this._side_panel.style.display = "flex";
this._top_panel.style.display = "flex";
this.setAttribute("settings", true);
}
this._show_config = !this._show_config;
this._plugin.resize.call(this, true);
this._hide_context_menu();
this.dispatchEvent(new CustomEvent("perspective-toggle-settings", {detail: this._show_config}));
}
this._show_config = !this._show_config;
this._plugin.resize.call(this, true);
this._hide_context_menu();
this.dispatchEvent(new CustomEvent("perspective-toggle-settings", {detail: this._show_config}));
}

// UI action
Expand Down
18 changes: 0 additions & 18 deletions packages/perspective/bench/config/benchmark.config.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/perspective/bench/config/report.config.js

This file was deleted.

10,000 changes: 0 additions & 10,000 deletions packages/perspective/bench/csv/flight_small.csv

This file was deleted.

42 changes: 42 additions & 0 deletions packages/perspective/bench/html/benchmark.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
Copyright (c) 2017, the Perspective Authors.
This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.
-->

<!DOCTYPE html>
<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

<script src="perspective.view.js"></script>
<script src="hypergrid.plugin.js"></script>
<script src="highcharts.plugin.js"></script>

<link rel='stylesheet' href="index.css">
<link rel='stylesheet' href="material.css" is="custom-style">

</head>

<body>

<perspective-viewer></perspective-viewer>

<script>
window.addEventListener('WebComponentsReady', async () => {
const req = await fetch("benchmark.json");
const json = await req.json();
const el = document.getElementsByTagName('perspective-viewer')[0];
el.load(json);
el.toggleConfig();
});
</script>

</body>

</html>
68 changes: 68 additions & 0 deletions packages/perspective/bench/js/bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const puppeteer = require("puppeteer");
const fs = require("fs");
const path = require("path");

const multi_template = (xs, ...ys) => ys[0].map((y, i) => [y, xs.reduce((z, x, ix) => (ys[ix] ? z + x + ys[ix][i] : z + x), "")]);

const UNPKG_VERSIONS = ["0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.2.10"];
const UNPKG_URLS = multi_template`https://unpkg.com/@jpmorganchase/perspective@${UNPKG_VERSIONS}/build/perspective.js`;

const OLD_FORMAT_UNPKG_VERSIONS = ["0.2.0-beta.3"];
const OLD_FORMAT_UNPKG_URLS = multi_template`https://unpkg.com/@jpmorganchase/perspective-examples@${OLD_FORMAT_UNPKG_VERSIONS}/build/perspective.js`;

const URLS = [].concat(OLD_FORMAT_UNPKG_URLS, UNPKG_URLS, [["master", "http://localhost:8080/perspective.js"]]);

const RUN_TEST = fs.readFileSync(path.join(__dirname, "browser_runtime.js")).toString();

async function run_version(browser, url) {
let page = await browser.newPage();
page.on("console", msg => console.log(` -> ${msg.text()}`));
page.on("pageerror", msg => console.log(` -> ${msg.message}`));

await page.setContent(`<html><head><script src="${url}" async></script><script>${RUN_TEST}</script></head><body></body></html>`);
await page.waitFor(() => window.hasOwnProperty("perspective"));

let results = await page.evaluate(async () => await window.run_test());
await page.close();

return results;
}

function transpose(json) {
const obj = {};
for (let key of Object.keys(json[0])) {
obj[key] = json.map(x => x[key]);
}
return obj;
}

async function run() {
let data = [],
version_index = 1;
for (let [version, url] of URLS) {
let browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox"]
});
console.log(`Running v${version} (${url})`);
let bins = await run_version(browser, url);
bins = bins.map(result => ({...result, version, version_index}));
version_index++;
data = data.concat(bins);
fs.writeFileSync(path.join(__dirname, "..", "..", "build", "benchmark.json"), JSON.stringify(transpose(data)));
fs.writeFileSync(path.join(__dirname, "..", "..", "build", "benchmark.html"), fs.readFileSync(path.join(__dirname, "..", "html", "benchmark.html")).toString());

await browser.close();
}
}

run();
Loading

0 comments on commit 794bbbb

Please sign in to comment.