Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed Jan 13, 2025
1 parent f40097d commit 934fa09
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 609 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Deploy to GitHub Pages
on:
push:
branches: ['main']
paths:
- 'gui/**'
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
Expand Down
5 changes: 2 additions & 3 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
"preview": "vite preview"
},
"dependencies": {
"@types/plotly.js": "^2.35.1",
"discrete-wavelets": "^5.0.15",
"plotly.js-dist-min": "^2.35.3",
"plotly.js": "^2.34.0",
"react-plotly.js": "^2.6.0",
"pyodide": "^0.27.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-plotly.js": "^2.6.0",
"wasmlets": "^0.0.4"
},
"devDependencies": {
Expand Down
32 changes: 31 additions & 1 deletion gui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { BenchmarkConfig, type BenchmarkSettings } from './components/BenchmarkConfig';
import { BenchmarkRunner, type BenchmarkResult } from './components/BenchmarkRunner';
import { ResultsTable } from './components/ResultsTable';
import { BenchmarkPlot } from './components/BenchmarkPlot';

interface StoredBenchmarkData {
config: BenchmarkSettings;
results: BenchmarkResult[];
}

const STORAGE_KEY = 'wasmlets-benchmark-data';

function App() {
const [isRunning, setIsRunning] = useState(false);
const [config, setConfig] = useState<BenchmarkSettings | null>(null);
const [results, setResults] = useState<BenchmarkResult[]>([]);

// Load stored data on component mount
useEffect(() => {
const storedData = localStorage.getItem(STORAGE_KEY);
if (storedData) {
try {
const data: StoredBenchmarkData = JSON.parse(storedData);
setConfig(data.config);
setResults(data.results);
} catch (error) {
console.error('Failed to parse stored benchmark data:', error);
localStorage.removeItem(STORAGE_KEY);
}
}
}, []);

const handleStartBenchmark = (settings: BenchmarkSettings) => {
setConfig(settings);
setIsRunning(true);
Expand All @@ -17,6 +39,13 @@ function App() {
const handleBenchmarkComplete = (benchmarkResults: BenchmarkResult[]) => {
setResults(benchmarkResults);
setIsRunning(false);

// Store the results and config
const dataToStore: StoredBenchmarkData = {
config: config!,
results: benchmarkResults
};
localStorage.setItem(STORAGE_KEY, JSON.stringify(dataToStore));
};

return (
Expand Down Expand Up @@ -46,6 +75,7 @@ function App() {
onClick={() => {
setResults([]);
setConfig(null);
localStorage.removeItem(STORAGE_KEY);
}}
className="w-full bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
>
Expand Down
19 changes: 6 additions & 13 deletions gui/src/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,19 @@ export async function runBenchmarks(o: {
const wasmletsInitTime = postWasmlets - preWasmlets;
console.log(`wasmlets initialized in ${wasmletsInitTime}ms`);

console.log("Initializing Pyodide...");
setProgress?.("Initializing Pyodide...");
// all this does is heat up the cache, so we can measure the time it takes to load the packages
// without internet speed affecting the results
await loadPyodide({
...(
o.pyodideIndexUrl ? { // don't work well if indexUrl is undefined but provided
indexURL: o.pyodideIndexUrl,
} : {}
),
packages: ["numpy", "pywavelets"],
const pyodideWarmup = await loadPyodide({
indexURL: o.pyodideIndexUrl
});
await pyodideWarmup.loadPackage(["numpy", "pywavelets"]);

const prePyodide = performance.now();
const pyodide = await loadPyodide({
...(
o.pyodideIndexUrl ? {
indexURL: o.pyodideIndexUrl,
} : {}),
packages: ["numpy", "pywavelets"],
indexURL: o.pyodideIndexUrl
});
await pyodide.loadPackage(["numpy", "pywavelets"]);

const postPyodide = performance.now();
const pyodideInitTime = postPyodide - prePyodide;
Expand Down
Loading

0 comments on commit 934fa09

Please sign in to comment.