mirror of
https://github.com/penpot/penpot.git
synced 2026-11-13 13:31:24 +00:00
Add a CLI under frontend/performance/benches/render_wasm that builds the renderer, runs seeded scenes (rects, plus, paths, masks) in headless Chromium and saves per-case timings. - build, run: prepare or reuse builds; measure cases with warmups, repetitions, deadlines - ab: build and compare Cargo feature configurations - compare, merge: median changes with bootstrap CIs between saved runs, guarded by scene, build and settings checks - purge: delete managed builds, runs or comparisons - GPU runs through `run-devenv --gpu` Lint, format and pnpm scripts now cover performance/ and its tests. AI-assisted-by: gpt-6.1-sol, deepseek-flash, muse-spark, glm-5.3, gpt6-astra, claude-5.5-sonnet, claude-haiku-5.5
50 lines
1.4 KiB
Clojure
50 lines
1.4 KiB
Clojure
(ns performance-tests.render-wasm.test-helpers
|
|
"Shared helpers for renderer benchmark scene tests.
|
|
|
|
These helpers assert nothing about shapes or the renderer. They only
|
|
capture errors, read root children in order, and run raw scopes so each
|
|
test namespace tells a complete story without copying bodies."
|
|
(:require
|
|
[app.common.uuid :as uuid]
|
|
[benches.render-wasm.builder :as builder]))
|
|
|
|
(defn failure-data
|
|
"Returns the ex-data of the thrown failure, or nil when `f` passes."
|
|
[f]
|
|
(try
|
|
(f)
|
|
nil
|
|
(catch :default cause
|
|
(ex-data cause))))
|
|
|
|
(defn child-ids
|
|
"Ids listed in the :shapes vector of `id`."
|
|
[snapshot id]
|
|
(get-in snapshot [:objects id :shapes]))
|
|
|
|
(defn children-of
|
|
"Child shapes of `id` in order."
|
|
[snapshot id]
|
|
(mapv (:objects snapshot) (child-ids snapshot id)))
|
|
|
|
(defn root-shapes
|
|
"Root children of a scene snapshot in creation order."
|
|
[snapshot]
|
|
(children-of snapshot uuid/zero))
|
|
|
|
(defn run-scope
|
|
"Runs `f` inside a raw scope and returns the scope state, so tests can
|
|
inspect partial builds without calling finish!."
|
|
[params f]
|
|
(let [state (builder/start params)]
|
|
(binding [builder/*state* state
|
|
builder/*defaults* {}]
|
|
(f))
|
|
state))
|
|
|
|
(defn selrect
|
|
"Selrect of `shape` as an [x y width height] tuple."
|
|
[shape]
|
|
[(:x (:selrect shape)) (:y (:selrect shape))
|
|
(:width (:selrect shape)) (:height (:selrect shape))])
|