From 41f7ce0bb32496fe32aebbc586559639519075a2 Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Thu, 25 May 2023 12:03:12 +0200 Subject: [PATCH] Added commands for easier profiling. (#1236) --- Cargo.toml | 4 ++++ frontend/package.json | 3 +++ frontend/wasm/Cargo.toml | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 510bf932..093df2dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,3 +61,7 @@ opt-level = 1 [profile.release] lto = "thin" + +[profile.profiling] +inherits = "release" +debug = true diff --git a/frontend/package.json b/frontend/package.json index a9f8308a..b31eaea5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,13 +13,16 @@ }, "scripts": { "start": "npm run build-wasm && concurrently -k \"parcel serve index.html --port 8080\" \"npm run watch:wasm\" || (npm run print-building-help && exit 1)", + "start-profiling": "npm run build-wasm-profiling && concurrently -k \"parcel serve index.html --port 8080\" \"npm run watch:wasm-profiling\" || (npm run print-building-help && exit 1)", "build": "npm run build-wasm-prod && npm run build-licenses && parcel build index.html || (npm run print-building-help && exit 1)", "build-licenses": "webpack build", "tauri:dev": "echo 'Make sure you build the wasm binary for tauri using `npm run tauri:build-wasm`' && parcel serve index.html --port 8080", "build-wasm": "wasm-pack build ./wasm --dev --target=web", + "build-wasm-profiling": "wasm-pack build ./wasm --profiling --target=web", "build-wasm-prod": "wasm-pack build ./wasm --release --target=web", "tauri:build-wasm": "wasm-pack build ./wasm --release --target=web -- --features tauri", "watch:wasm": "cargo watch --postpone --watch-when-idle --workdir wasm --shell \"wasm-pack build . --dev --target=web -- --color always\"", + "watch:wasm-profiling": "cargo watch --postpone --watch-when-idle --workdir wasm --shell \"wasm-pack build . --profiling --target=web -- --color always\"", "--------------------": "", "print-building-help": "echo 'Graphite project failed to build. Did you remember to `npm install` the dependencies in `/frontend`?'", "print-linting-help": "echo 'Graphite project had lint errors, or may have otherwise failed. In the latter case, did you remember to `npm install` the dependencies in `/frontend`?'" diff --git a/frontend/wasm/Cargo.toml b/frontend/wasm/Cargo.toml index da42b290..1e3f9a95 100644 --- a/frontend/wasm/Cargo.toml +++ b/frontend/wasm/Cargo.toml @@ -58,3 +58,11 @@ wasm-opt = ["-Os"] debug-js-glue = false demangle-name-section = false dwarf-debug-info = false + +[package.metadata.wasm-pack.profile.profiling] +wasm-opt = ["-Os", "-g"] + +[package.metadata.wasm-pack.profile.profiling.wasm-bindgen] +debug-js-glue = true +demangle-name-section = true +dwarf-debug-info = true