mirror of
https://github.com/penpot/penpot.git
synced 2026-11-17 07:30:35 +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
69 lines
2.3 KiB
Clojure
69 lines
2.3 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
|
|
|
(ns benches.render-wasm.scenes.plus
|
|
"Plus signs made of two open line subpaths"
|
|
(:require
|
|
[app.common.types.path :as path]
|
|
[benches.render-wasm.builder :as sb]
|
|
[benches.render-wasm.declarations :as decl]
|
|
[benches.render-wasm.random :refer [rng-int]]
|
|
[benches.render-wasm.runtime.camera :as camera]))
|
|
|
|
(def ^:private default-params
|
|
{:count 1000 :width 1920 :height 1080})
|
|
|
|
(def ^:private schema:params
|
|
[:map {:closed true}
|
|
[:count [:int {:min 1 :max 100000}]]
|
|
[:width [:int {:min 100}]]
|
|
[:height [:int {:min 100}]]])
|
|
|
|
(defn- plus-content
|
|
[{:keys [width height]}]
|
|
(fn [rng]
|
|
(let [x (rng-int rng 20 width)
|
|
y (rng-int rng 20 height)
|
|
r (rng-int rng 10 40)]
|
|
(path/from-plain
|
|
[{:command :move-to :params {:x (- x r) :y y}}
|
|
{:command :line-to :params {:x (+ x r) :y y}}
|
|
{:command :move-to :params {:x x :y (- y r)}}
|
|
{:command :line-to :params {:x x :y (+ y r)}}]))))
|
|
|
|
|
|
(decl/defscene :plus
|
|
{:description "Plus signs made of two open line subpaths"
|
|
:params-schema schema:params}
|
|
[params]
|
|
(let [params (merge default-params params)]
|
|
(sb/scene {:seed (:seed params)
|
|
:root {:x 0 :y 0 :width (:width params) :height (:height params)}
|
|
:defaults {:path {:content (plus-content params)
|
|
:fills []
|
|
:strokes (sb/gen-vector (sb/gen-stroke 4))}}}
|
|
(doseq [_ (range (:count params))]
|
|
(sb/path)))))
|
|
|
|
(def ^:private base-view {:scale 1 :x 0 :y 0})
|
|
|
|
(decl/defcase :plus/load
|
|
{:params default-params :view base-view :context :fresh :preparation {:render :none}}
|
|
[rtx]
|
|
(camera/load* rtx))
|
|
|
|
(decl/defcase :plus/pan
|
|
{:params default-params :view base-view :context :reuse
|
|
:reset #(camera/restore % (get-in % [:case :view]))}
|
|
[rtx]
|
|
(camera/pan* rtx {:steps 20 :dx 140 :dy 60 :settle-ms 100}))
|
|
|
|
(decl/defcase :plus/zoom
|
|
{:params default-params :view base-view :context :reuse
|
|
:reset #(camera/restore % (get-in % [:case :view]))}
|
|
[rtx]
|
|
(camera/zoom* rtx {:steps 20 :factor 1.4 :settle-ms 100}))
|