Skip to content

Commit

Permalink
Publish benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Jul 17, 2023
1 parent ff186da commit 543cd24
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 9 deletions.
258 changes: 256 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,120 @@ jobs:
- name: WebAssembly Test
run: yarn test_js --ci

############################# ##############################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~# #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~/########\~~~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~# #~~~~~~~~~|##|~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~|##|~~~~~~# #~~~~~~~~~|##|~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~|######|~~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~~~~~~~~~~~~|##|~~~~~~# #~~~~~~~~~~~~~~~~~|##|~~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~# #~~~~~~~~~|##|~~~~|##|~~~~~~~#
#~~~~~~~~~\#########/~~~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~# ##### #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Three And a Half # # . # # Benchmarking #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~# ##### #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
benchmark_js:
needs: [build_js]
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
os: [ubuntu-20.04]
node-version: [18.x]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

##########
# Caches #
##########
################
# Yarn Cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
shell: bash
if: ${{ needs.initialize.outputs.SKIP_CACHE == 'false' }}

- name: Setup yarn cache
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
~/.cache/ms-playwright
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
if: ${{ needs.initialize.outputs.SKIP_CACHE == 'false' }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache-dependency-path: yarn.lock

################
# Dependencies #
################
################
# JS
- name: Install yarn
run: npm install -g yarn

- name: Install js dependencies
run: yarn
env:
PSP_SKIP_EMSDK_INSTALL: 1

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~ Build Pipelines ~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- uses: actions/download-artifact@v3
with:
name: perspective-dist
path: packages/perspective/dist/

- uses: actions/download-artifact@v3
with:
name: perspective-jupyterlab-dist
path: packages/perspective-jupyterlab/dist/

- uses: actions/download-artifact@v3
with:
name: perspective-viewer-d3fc-dist
path: packages/perspective-viewer-d3fc/dist

- uses: actions/download-artifact@v3
with:
name: perspective-viewer-datagrid-dist
path: packages/perspective-viewer-datagrid/dist

- uses: actions/download-artifact@v3
with:
name: perspective-viewer-openlayers-dist
path: packages/perspective-viewer-openlayers/dist

- uses: actions/download-artifact@v3
with:
name: perspective-workspace-dist
path: packages/perspective-workspace/dist

- uses: actions/download-artifact@v3
with:
name: perspective-viewer-dist
path: rust/perspective-viewer/dist

- name: Benchmarks
run: yarn bench

- uses: actions/upload-artifact@v3
with:
name: perspective-js-benchmarks
path: tools/perspective-bench/dist/benchmark-js.arrow

##########################################################################################################################
##########################################################################################################################

Expand Down Expand Up @@ -1034,7 +1148,10 @@ jobs:
if: ${{ matrix.os == 'macos-11' }}

build_pyodide:
runs-on: ubuntu-22.04
strategy:
matrix:
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
needs: [initialize]
env:
PYODIDE_VERSION: 0.23.2
Expand Down Expand Up @@ -1575,6 +1692,129 @@ jobs:
##########################################################################################################################
##########################################################################################################################

############################ ##############################
#~~~~~~~~~~~~~~~~~~~~~~~~~~# #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~|#############|~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~|#|~~~~~~~/##/~~~~~~# #~~~~~~~~~|##|~~~~~~~~~~~~~~~#
#~~~~~~|#|~~~~~/##/~~~~~~~~# #~~~~~~~~~|##|~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~/##/~~~~~~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~~~~~/##/~~~~~~~~~~~~# #~~~~~~~~~~~~~~~~~|##|~~~~~~~#
#~~~~~~~~/##/~~~~~~~~~~~~~~# #~~~~~~~~~|##|~~~~|##|~~~~~~~#
#~~~~~~/##/~~~~~~~~~~~~~~~~# #~~~~~~~~~|##########|~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~# ##### #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Seven and a Half # # . # # Benchmarking #
#~~~~~~~~~~~~~~~~~~~~~~~~~~# ##### #~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
benchmark_python:
######################################################################
# Run Python build first, then use the artifacts in the python tests #
######################################################################
needs: [build_python]
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.11]
node-version: [18.x]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

##########
# Caches #
##########
################
# Yarn Cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
shell: bash
if: ${{ needs.initialize.outputs.SKIP_CACHE == 'false' }}

- name: Setup yarn cache
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
~/.cache/ms-playwright
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
if: ${{ needs.initialize.outputs.SKIP_CACHE == 'false' }}

################
# Pip Cache
- name: Setup pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
if: ${{ needs.initialize.outputs.SKIP_CACHE == 'false' }}

###############################
# Language and Compiler Setup #
###############################
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache-dependency-path: yarn.lock

################
# Dependencies #
################
################
# JS
- name: Install yarn
run: npm install -g yarn

- name: Install js dependencies
run: yarn
env:
PSP_SKIP_EMSDK_INSTALL: 1

################
# Python
- name: Install python dependencies
run: yarn _requires_python

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~ Build Pipelines ~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#################
# Python - Test #
#################
# Download artifact
- uses: actions/download-artifact@v3
with:
name: perspective-python-dist-${{ matrix.os }}-${{ matrix.python-version }}

# Install artifact in-place so tests work as-is
- name: Install wheel (Linux)
run: python -m pip install -U *manylinux2014*.whl --target python/perspective
if: ${{ runner.os == 'Linux' }}

# Run tests
- name: Python Test Steps
run: yarn bench

- uses: actions/upload-artifact@v3
with:
name: perspective-python-benchmarks
path: tools/perspective-bench/dist/benchmark-python.arrow
##########################################################################################################################
##########################################################################################################################

##########################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~/#########\~~~~~~~~~~~~~~#
Expand All @@ -1596,9 +1836,14 @@ jobs:
test_python_sdist,
build_pyodide,
test_js,
benchmark_js,
benchmark_python,
]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
strategy:
matrix:
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -1734,6 +1979,14 @@ jobs:
with:
name: perspective-python-sdist

- uses: actions/download-artifact@v3
with:
name: perspective-js-benchmarks

- uses: actions/download-artifact@v3
with:
name: perspective-python-benchmarks

- name: NPM pack
run: |
npm pack \
Expand All @@ -1760,5 +2013,6 @@ jobs:
*.whl
*.tar.gz
*.tgz
*.arrow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@ test-results/
playwright-report/
playwright/.cache/

.pyodide-xbuildenv
.pyodide-xbuildenv
python/perspective/bench/runtime/benchmark_venv
2 changes: 2 additions & 0 deletions examples/blocks/src/olympics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />

<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/pro.css" />
<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-workspace/dist/css/pro.css" />

<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="/node_modules/@finos/perspective-workspace/dist/cdn/perspective-workspace.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>
Expand Down
10 changes: 9 additions & 1 deletion python/perspective/bench/runtime/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ def write_results(self):
with open(ARROW_PATH, "wb") as file:
arrow = self._table.view().to_arrow()
file.write(arrow)

html_path = os.path.join(os.path.dirname(__file__), "benchmark-python.html")
out_path = os.path.join(os.path.dirname(ARROW_PATH), "benchmark-python.html")

with open(html_path, "r") as input:
with open(out_path, "w") as output:
output.write(input.read())

self._WROTE_RESULTS = True

def run_method(self, func, *args, **kwargs):
Expand Down Expand Up @@ -262,7 +270,7 @@ def run(self, version):
if os.path.exists(ARROW_PATH):
# if arrow exists, append to it
with open(ARROW_PATH, "rb") as arr:
print("Reading table from pre-existing benchmark.arrow")
print("Reading table from pre-existing benchmark-python.arrow")
self._table = Table(arr.read())
self._table.update([result])
else:
Expand Down
50 changes: 50 additions & 0 deletions python/perspective/bench/runtime/benchmark-python.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
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 type="module" src="node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>

<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/themes.css" />

<style>
perspective-viewer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
</style>
</head>

<body>
<perspective-viewer></perspective-viewer>

<script type="module">
import perspective from "/node_modules/@finos/perspective/dist/cdn/perspective.js";
window.addEventListener("DOMContentLoaded", async () => {
const el = document.getElementsByTagName("perspective-viewer")[0];
el.addEventListener("perspective-config-update", async () => localStorage.setItem("layout", JSON.stringify(await el.save())));
const req = await fetch("benchmark-python.arrow");
const arrow = await req.arrayBuffer();
const worker = perspective.worker();
const table = await worker.table(arrow);
el.load(table);
el.restore(JSON.parse(localStorage.getItem("layout")));
el.toggleConfig();
});
</script>
</body>
</html>
Loading

0 comments on commit 543cd24

Please sign in to comment.