Blender's GPU Accelerated UI, Decoupled from it's original codebase. Supports Rust, Python, JS, React, C & C++. Twice as good as GPUI
chore: do perf bench
Preetham Pemmasani551a439e6768
diff --git a/README.md b/README.mdindex 370e860..8500d02 100644--- a/README.md+++ b/README.md@@ -366,6 +366,55 @@ More: [ARCHITECTURE.md](ARCHITECTURE.md).## Performance+### Start time and battery++The same small settings window (a label, text field, checkbox, slider and+button) written each of the five ways, from [`bench/apps`](bench/apps), on+BUI's CPU renderer (the default) and its GPU renderer (`BUI_GPU=1`). The last+rows are one gpui-syntax source file,+[`settings.rs`](bindings/rust/bench/common/settings.rs), compiled unchanged+against blenderui, Zed's [gpui](https://crates.io/crates/gpui) and+[gpui-fast](https://github.com/longbridge/gpui-fast). gpui has no form widgets,+so there the controls are styled divs.++Median of 10 launches, from process start until the first frame is on screen.+Ryzen 7 5800U laptop, Windows 11, on AC power, Python 3.14, Node 22:++| | Renderer | Start time | CPU used to start | Memory (idle) | Idle CPU per minute |+| ------------------------------ | -------- | ---------: | ----------------: | ------------: | ------------------: |+| Rust (HTML + CSS) | CPU | **38 ms** | **27 ms** | **13 MB** | **0 ms** |+| | GPU | 42 ms | 61 ms | 31 MB | 1.8 ms |+| JavaScript (React, Node.js) | CPU | 94 ms | 100 ms | 48 MB | 68 ms |+| | GPU | 99 ms | 131 ms | 60 MB | 71 ms |+| Blender components (Python) | CPU | 112 ms | 86 ms | 23 MB | 0 ms |+| | GPU | 116 ms | 125 ms | 32 MB | 1.7 ms |+| tkinter syntax (Python) | CPU | 139 ms | 112 ms | 25 MB | 0.2 ms |+| | GPU | 159 ms | 157 ms | 43 MB | 2.4 ms |+| Qt syntax (Python) | CPU | 156 ms | 123 ms | 27 MB | 0 ms |+| | GPU | 161 ms | 160 ms | 36 MB | 1.2 ms |+| **Same gpui code:** blenderui | CPU | **40 ms** | **27 ms** | **15 MB** | **0 ms** |+| blenderui | GPU | 43 ms | 60 ms | 31 MB | 2.1 ms |+| gpui | GPU | 231 ms | 226 ms | 29 MB | 743 ms |+| gpui-fast | GPU | 226 ms | 217 ms | 31 MB | 2.5 ms |++On the same code, blenderui shows its first frame about 5× sooner than gpui+and gpui-fast, spends about 8× less CPU getting there, and on the CPU renderer+uses half the memory. Idle, gpui keeps about 1.2 % of a core busy; blenderui+uses none.++Laptops can't report energy per app, so battery cost is measured by the CPU+time an app causes: the CPU it spends starting up, and the CPU it uses over 20+seconds while the window sits idle (what drains a battery while an app is+open). BUI redraws only when something changes and otherwise sleeps, so idle+use is near zero on either renderer. The GPU renderer starts a little slower+and uses more memory (the Direct3D device), and pays off on large, animated+scenes (below). Node's event loop accounts for the JavaScript idle figure,+Python's times include starting the interpreter, and memory doesn't count GPU+memory. Run it yourself with `py -3 bench/run.py` (the script lists what to+build first).++### Frame times+Python and C, on the full component demo (520×900):| Frame | Time |diff --git a/bench/apps/components_app.py b/bench/apps/components_app.pynew file mode 100644index 0000000..0150fc2--- /dev/null+++ b/bench/apps/components_app.py@@ -0,0 +1,23 @@+"""Benchmark app, Blender components: the shared small UI. Prints "ready" once+the first frame is on screen, then idles until the harness stops it."""+from blenderui import host+from blenderui.components import App, Button, Checkbox, Label, NumberSlider, Panel, TextField++app = App("bench", (360, 260),+ Panel("Settings",+ TextField("Name", "Cube"),+ Checkbox("Shadows", True),+ NumberSlider("Strength", 1.0, min=0, max=10)),+ Button("Apply"))+win = app.open()+++def poll():+ if win.frames > 0:+ print("ready", flush=True)+ else:+ win.after(1, poll)+++win.after(1, poll)+host.run()diff --git a/bench/apps/js_app.js b/bench/apps/js_app.jsnew file mode 100644index 0000000..c4edc96--- /dev/null+++ b/bench/apps/js_app.js@@ -0,0 +1,17 @@+// Benchmark app, JavaScript (React on Node): the shared small UI. Prints+// "ready" once the first frame is on screen, then idles until the harness+// stops it.+'use strict'+const { render, createElement: h } = require('@blender-ui/react')++function App () {+ return h('main', { styled: '', className: 'p-3 flex flex-col gap-2' },+ h('span', null, 'Settings'),+ h('input', { defaultValue: 'Cube' }),+ h('label', null, h('input', { type: 'checkbox', defaultChecked: true }), ' Shadows'),+ h('input', { type: 'range', min: 0, max: 10 }),+ h('button', null, 'Apply'))+}++const { window } = render(h(App), { title: 'bench', width: 360, height: 260 })+window.requestAnimationFrame(() => console.log('ready'))diff --git a/bench/apps/qt_app.py b/bench/apps/qt_app.pynew file mode 100644index 0000000..0e224f6--- /dev/null+++ b/bench/apps/qt_app.py@@ -0,0 +1,28 @@+"""Benchmark app, Qt syntax: the shared small UI. Prints "ready" once the+first frame is on screen, then idles until the harness stops it."""+from blenderui.qtsyntax import (QApplication, QCheckBox, QLabel, QLineEdit, QPushButton, QSlider, QTimer,+ QVBoxLayout, QWidget, Qt)++app = QApplication([])+w = QWidget()+w.setWindowTitle("bench")+w.resize(360, 260)+lay = QVBoxLayout()+lay.addWidget(QLabel("Settings"))+lay.addWidget(QLineEdit("Cube"))+lay.addWidget(QCheckBox("Shadows"))+lay.addWidget(QSlider(Qt.Horizontal))+lay.addWidget(QPushButton("Apply"))+w.setLayout(lay)+w.show()+++def poll():+ if w._window is not None and w._window.frames > 0:+ print("ready", flush=True)+ else:+ QTimer.singleShot(1, poll)+++QTimer.singleShot(1, poll)+app.exec()diff --git a/bench/apps/tk_app.py b/bench/apps/tk_app.pynew file mode 100644index 0000000..483bde0--- /dev/null+++ b/bench/apps/tk_app.py@@ -0,0 +1,28 @@+"""Benchmark app, tkinter syntax: the shared small UI. Prints "ready" once the+first frame is on screen, then idles until the harness stops it."""+import sys++import blenderui.tksyntax as tk+from blenderui.tksyntax import ttk++root = tk.Tk()+root.title("bench")+root.geometry("360x260")+ttk.Label(root, text="Settings").pack(anchor="w", padx=12, pady=(12, 4))+name = tk.StringVar(value="Cube")+ttk.Entry(root, textvariable=name).pack(fill="x", padx=12, pady=4)+ttk.Checkbutton(root, text="Shadows").pack(anchor="w", padx=12, pady=4)+ttk.Scale(root, from_=0, to=10).pack(fill="x", padx=12, pady=4)+ttk.Button(root, text="Apply").pack(anchor="w", padx=12, pady=4)+++def poll():+ if root._window.frames > 0:+ print("ready", flush=True)+ else:+ root.after(1, poll)+++root.after(1, poll)+root.mainloop()+sys.exit(0)diff --git a/bench/results.json b/bench/results.jsonnew file mode 100644index 0000000..0c19d20--- /dev/null+++ b/bench/results.json@@ -0,0 +1,148 @@+{+ "runs": 10,+ "idle_seconds": 20.0,+ "python": "3.14.0",+ "cpu": "AMD Ryzen 7 5800U with Radeon Graphics",+ "results": [+ {+ "name": "tkinter syntax (Python), CPU",+ "start_ms": 138.6,+ "start_best_ms": 129.6,+ "start_cpu_ms": 112.4,+ "memory_mb": 25.2,+ "memory_idle_mb": 25.1,+ "idle_cpu_pct": 0.0004,+ "idle_cpu_ms_per_min": 0.2+ },+ {+ "name": "tkinter syntax (Python), GPU",+ "start_ms": 159.2,+ "start_best_ms": 147.3,+ "start_cpu_ms": 157.0,+ "memory_mb": 33.0,+ "memory_idle_mb": 43.3,+ "idle_cpu_pct": 0.004,+ "idle_cpu_ms_per_min": 2.4+ },+ {+ "name": "Qt syntax (Python), CPU",+ "start_ms": 155.6,+ "start_best_ms": 152.1,+ "start_cpu_ms": 122.9,+ "memory_mb": 27.0,+ "memory_idle_mb": 27.4,+ "idle_cpu_pct": 0.0,+ "idle_cpu_ms_per_min": 0.0+ },+ {+ "name": "Qt syntax (Python), GPU",+ "start_ms": 161.3,+ "start_best_ms": 154.2,+ "start_cpu_ms": 160.4,+ "memory_mb": 34.6,+ "memory_idle_mb": 35.6,+ "idle_cpu_pct": 0.002,+ "idle_cpu_ms_per_min": 1.2+ },+ {+ "name": "Blender components (Python), CPU",+ "start_ms": 111.8,+ "start_best_ms": 105.4,+ "start_cpu_ms": 86.0,+ "memory_mb": 23.0,+ "memory_idle_mb": 23.1,+ "idle_cpu_pct": 0.0,+ "idle_cpu_ms_per_min": 0.0+ },+ {+ "name": "Blender components (Python), GPU",+ "start_ms": 116.1,+ "start_best_ms": 105.5,+ "start_cpu_ms": 124.8,+ "memory_mb": 30.1,+ "memory_idle_mb": 31.8,+ "idle_cpu_pct": 0.0028,+ "idle_cpu_ms_per_min": 1.7+ },+ {+ "name": "Rust (HTML + CSS), CPU",+ "start_ms": 37.7,+ "start_best_ms": 27.8,+ "start_cpu_ms": 26.6,+ "memory_mb": 12.0,+ "memory_idle_mb": 12.6,+ "idle_cpu_pct": 0.0,+ "idle_cpu_ms_per_min": 0.0+ },+ {+ "name": "Rust (HTML + CSS), GPU",+ "start_ms": 42.3,+ "start_best_ms": 36.8,+ "start_cpu_ms": 60.8,+ "memory_mb": 16.6,+ "memory_idle_mb": 30.7,+ "idle_cpu_pct": 0.003,+ "idle_cpu_ms_per_min": 1.8+ },+ {+ "name": "JavaScript (React on Node.js), CPU",+ "start_ms": 93.9,+ "start_best_ms": 88.0,+ "start_cpu_ms": 100.4,+ "memory_mb": 48.4,+ "memory_idle_mb": 47.8,+ "idle_cpu_pct": 0.1136,+ "idle_cpu_ms_per_min": 68.2+ },+ {+ "name": "JavaScript (React on Node.js), GPU",+ "start_ms": 98.6,+ "start_best_ms": 88.5,+ "start_cpu_ms": 131.4,+ "memory_mb": 52.5,+ "memory_idle_mb": 60.3,+ "idle_cpu_pct": 0.1188,+ "idle_cpu_ms_per_min": 71.3+ },+ {+ "name": "gpui scene: blenderui, CPU",+ "start_ms": 40.0,+ "start_best_ms": 35.6,+ "start_cpu_ms": 27.3,+ "memory_mb": 11.9,+ "memory_idle_mb": 14.5,+ "idle_cpu_pct": 0.0,+ "idle_cpu_ms_per_min": 0.0+ },+ {+ "name": "gpui scene: blenderui, GPU",+ "start_ms": 43.4,+ "start_best_ms": 35.9,+ "start_cpu_ms": 60.1,+ "memory_mb": 17.3,+ "memory_idle_mb": 30.6,+ "idle_cpu_pct": 0.0036,+ "idle_cpu_ms_per_min": 2.1+ },+ {+ "name": "gpui scene: gpui",+ "start_ms": 230.6,+ "start_best_ms": 227.8,+ "start_cpu_ms": 226.3,+ "memory_mb": 27.7,+ "memory_idle_mb": 29.3,+ "idle_cpu_pct": 1.238,+ "idle_cpu_ms_per_min": 742.8+ },+ {+ "name": "gpui scene: gpui-fast",+ "start_ms": 225.5,+ "start_best_ms": 214.6,+ "start_cpu_ms": 217.4,+ "memory_mb": 29.7,+ "memory_idle_mb": 31.2,+ "idle_cpu_pct": 0.0042,+ "idle_cpu_ms_per_min": 2.5+ }+ ]+}\ No newline at end of filediff --git a/bench/run.py b/bench/run.pynew file mode 100644index 0000000..4c6b61d--- /dev/null+++ b/bench/run.py@@ -0,0 +1,194 @@+"""Start time and battery proxies for the five ways to write a BUI app.++Each app in bench/apps (and the Rust example `bench_app`) shows the same small+UI and prints "ready" once its first frame is on screen. For every binding+this script:++* launches it N times and takes the median wall time from launch to "ready",+ the CPU time it used to get there, and its memory then;+* keeps one launch open and idle for a while and measures the CPU it uses.++Laptops can't report energy per process, so the battery numbers are proxies:+CPU time spent starting up, and CPU used while the window sits idle (an idle+UI that uses no CPU lets the processor sleep).++ py -3 bench/run.py [runs=10] [idle_seconds=10]++Needs: the buipy extension built for this Python (cmake --build <dir> --target+buipy), the Node addon (cd bindings/node && npm run build), and the Rust+example built with `cargo build --release --example bench_app` in+bindings/rust, and the gpui comparison with `cargo build --release --bins` in+bindings/rust/bench. Every BUI app runs twice, with BUI_GPU=0 (CPU renderer)+and BUI_GPU=1 (GPU renderer). Windows only (process times come from the Win32+API).+"""+from __future__ import annotations++import ctypes+import ctypes.wintypes as wt+import glob+import json+import os+import statistics+import subprocess+import sys+import threading+import time++ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+APPS = os.path.join(ROOT, "bench", "apps")++k32 = ctypes.WinDLL("kernel32", use_last_error=True)+psapi = ctypes.WinDLL("psapi")+++class PMC(ctypes.Structure):+ _fields_ = [("cb", wt.DWORD), ("PageFaultCount", wt.DWORD), ("PeakWorkingSetSize", ctypes.c_size_t),+ ("WorkingSetSize", ctypes.c_size_t), ("QuotaPeakPagedPoolUsage", ctypes.c_size_t),+ ("QuotaPagedPoolUsage", ctypes.c_size_t), ("QuotaPeakNonPagedPoolUsage", ctypes.c_size_t),+ ("QuotaNonPagedPoolUsage", ctypes.c_size_t), ("PagefileUsage", ctypes.c_size_t),+ ("PeakPagefileUsage", ctypes.c_size_t), ("PrivateUsage", ctypes.c_size_t)]+++def _cpu_hz() -> float:+ """The CPU's rated clock (the rate cycle counts tick at)."""+ import winreg+ with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0") as k:+ return winreg.QueryValueEx(k, "~MHz")[0] * 1e6+++CPU_HZ = _cpu_hz()+++def cpu_name() -> str:+ import winreg+ with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0") as k:+ return winreg.QueryValueEx(k, "ProcessorNameString")[0].strip()+++def cpu_seconds(handle) -> float:+ """CPU time of a process (all threads, user + kernel) in seconds, from its+ exact cycle count (GetProcessTimes only counts 15.6 ms scheduler ticks)."""+ cycles = ctypes.c_ulonglong()+ if not k32.QueryProcessCycleTime(handle, ctypes.byref(cycles)):+ return float("nan")+ return cycles.value / CPU_HZ+++def memory_mb(handle) -> float:+ m = PMC()+ m.cb = ctypes.sizeof(PMC)+ psapi.GetProcessMemoryInfo(handle, ctypes.byref(m), m.cb)+ return m.WorkingSetSize / 1048576+++def find_pyd() -> str | None:+ hits = glob.glob(os.path.join(ROOT, "build*", "**", "buipy*.pyd"), recursive=True)+ tag = f"cp{sys.version_info.major}{sys.version_info.minor}"+ hits = [h for h in hits if tag in os.path.basename(h)]+ return os.path.dirname(max(hits, key=os.path.getmtime)) if hits else None+++def variants():+ py_env = dict(os.environ, PYTHONPATH=os.pathsep.join(filter(None, [os.path.join(ROOT, "bindings", "python"),+ find_pyd()])))+ js_env = dict(os.environ, NODE_PATH=os.path.join(ROOT, "bindings", "node_modules"), NODE_ENV="production")+ rust_exe = os.path.join(ROOT, "bindings", "rust", "target", "release", "examples", "bench_app.exe")+ bench_bin = os.path.join(ROOT, "bindings", "rust", "bench", "target", "release")+ py = [sys.executable, "-X", "frozen_modules=on"]+ ours = [+ ("tkinter syntax (Python)", py + [os.path.join(APPS, "tk_app.py")], py_env),+ ("Qt syntax (Python)", py + [os.path.join(APPS, "qt_app.py")], py_env),+ ("Blender components (Python)", py + [os.path.join(APPS, "components_app.py")], py_env),+ ("Rust (HTML + CSS)", [rust_exe], dict(os.environ)),+ ("JavaScript (React on Node.js)", ["node", os.path.join(APPS, "js_app.js")], js_env),+ # the same gpui-syntax source on blenderui, gpui and gpui-fast+ ("gpui scene: blenderui", [os.path.join(bench_bin, "bui-settings.exe")], dict(os.environ)),+ ]+ out = []+ for name, cmd, env in ours:+ for renderer, flag in (("CPU", "0"), ("GPU", "1")):+ out.append((f"{name}, {renderer}", cmd, dict(env, BUI_GPU=flag)))+ out.append(("gpui scene: gpui", [os.path.join(bench_bin, "gpui-settings.exe")], dict(os.environ)))+ out.append(("gpui scene: gpui-fast", [os.path.join(bench_bin, "gpui-fast-settings.exe")], dict(os.environ)))+ return out+++def launch(cmd, env, timeout=30.0):+ """Start `cmd`; returns (process, seconds to "ready", CPU seconds then, MB then)."""+ t0 = time.perf_counter()+ p = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)+ got = threading.Event()++ def read():+ for line in p.stdout:+ if line.strip() == "ready":+ got.set()+ return++ threading.Thread(target=read, daemon=True).start()+ if not got.wait(timeout):+ err = p.stderr.read() if p.poll() is not None else ""+ p.kill()+ raise RuntimeError(f"{cmd[-1]}: no first frame within {timeout}s\n{err[-2000:]}")+ dt = time.perf_counter() - t0+ h = int(p._handle) # the Popen handle has query rights+ return p, dt, cpu_seconds(h), memory_mb(h)+++def stop(p):+ p.kill()+ p.wait()+++def bench(name, cmd, env, runs, idle_s):+ launch(cmd, env)[0].kill() # warm the file cache+ starts, cpus, mems = [], [], []+ for _ in range(runs):+ p, dt, cpu, mem = launch(cmd, env)+ starts.append(dt * 1000)+ cpus.append(cpu * 1000)+ mems.append(mem)+ stop(p)+ # idle: one window left alone; skip a second for deferred startup work+ p, *_ = launch(cmd, env)+ h = int(p._handle)+ time.sleep(1.0)+ c0, t0 = cpu_seconds(h), time.perf_counter()+ time.sleep(idle_s)+ idle = (cpu_seconds(h) - c0) / (time.perf_counter() - t0) * 100+ mem_idle = memory_mb(h)+ stop(p)+ return {+ "name": name,+ "start_ms": round(statistics.median(starts), 1),+ "start_best_ms": round(min(starts), 1),+ "start_cpu_ms": round(statistics.median(cpus), 1),+ "memory_mb": round(statistics.median(mems), 1),+ "memory_idle_mb": round(mem_idle, 1),+ "idle_cpu_pct": round(idle, 4),+ "idle_cpu_ms_per_min": round(idle / 100 * 60_000, 1),+ }+++def main():+ runs = int(sys.argv[1]) if len(sys.argv) > 1 else 10+ idle_s = float(sys.argv[2]) if len(sys.argv) > 2 else 10.0+ results = []+ for name, cmd, env in variants():+ try:+ r = bench(name, cmd, env, runs, idle_s)+ except Exception as e: # noqa: BLE001 - report and go on+ print(f"{name}: FAILED: {e}", file=sys.stderr)+ continue+ print(json.dumps(r), flush=True)+ results.append(r)+ out = os.path.join(ROOT, "bench", "results.json")+ with open(out, "w", encoding="utf-8") as f:+ json.dump({"runs": runs, "idle_seconds": idle_s, "python": sys.version.split()[0], "cpu": cpu_name(),+ "results": results}, f, indent=2)+ print(f"wrote {out}")+++if __name__ == "__main__":+ main()diff --git a/bindings/rust/bench/bui-bench/src/bin/bui-settings.rs b/bindings/rust/bench/bui-bench/src/bin/bui-settings.rsnew file mode 100644index 0000000..1fa0cc5--- /dev/null+++ b/bindings/rust/bench/bui-bench/src/bin/bui-settings.rs@@ -0,0 +1,14 @@+//! The settings window (common/settings.rs) on blenderui. `BUI_GPU=1` for the+//! GPU renderer, `BUI_GPU=0` for the CPU one.+use blenderui::prelude::*;++include!("../../../common/settings.rs");++fn main() {+ Application::new().run(|cx: &mut App| {+ let bounds = Bounds { origin: point(px(100.0), px(100.0)), size: size(px(360.0), px(260.0)) };+ cx.open_window(WindowOptions { window_bounds: Some(WindowBounds::Windowed(bounds)), ..Default::default() },+ |_, cx| cx.new(|_| Settings { renders: 0 }))+ .unwrap();+ });+}diff --git a/bindings/rust/bench/common/settings.rs b/bindings/rust/bench/common/settings.rsnew file mode 100644index 0000000..9166157--- /dev/null+++ b/bindings/rust/bench/common/settings.rs@@ -0,0 +1,41 @@+// The startup benchmark's settings window in gpui syntax, compiled unchanged+// against blenderui, gpui and gpui-fast (bench/run.py). gpui has no form+// widgets, so the controls are styled divs. The including file imports the+// framework (`div`, `px`, `rgb`, `Render`, `Window` ...), defines `run_app`+// and calls `settings_main()`.+//+// "ready" is printed on the second render: frameworks render again after the+// first frame was presented when asked with `request_animation_frame`.++struct Settings {+ renders: u32,+}++impl Render for Settings {+ fn render(&mut self, window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {+ self.renders += 1;+ if self.renders == 1 {+ window.request_animation_frame();+ } else if self.renders == 2 {+ println!("ready");+ }+ let field = |label: &'static str| {+ div().flex().items_center().gap(px(8.0))+ .child(div().w(px(70.0)).text_color(rgb(0xb8b8b8)).child(label))+ .child(div().flex_1().h(px(20.0)).px(px(6.0)).rounded(px(4.0)).bg(rgb(0x1d1d1d))+ .border_1().border_color(rgb(0x3d3d3d)).text_color(rgb(0xe6e6e6)).child("Cube"))+ };+ div()+ .size_full().flex().flex_col().gap(px(8.0)).p(px(12.0))+ .bg(rgb(0x303030)).text_color(rgb(0xe6e6e6)).text_size(px(13.0))+ .child(div().text_size(px(16.0)).child("Settings"))+ .child(field("Name"))+ .child(div().flex().items_center().gap(px(8.0))+ .child(div().size(px(14.0)).rounded(px(3.0)).bg(rgb(0x4772b3)))+ .child("Shadows"))+ .child(div().h(px(20.0)).rounded(px(4.0)).bg(rgb(0x545454))+ .child(div().w(px(120.0)).h(px(20.0)).rounded(px(4.0)).bg(rgb(0x4772b3))))+ .child(div().w(px(80.0)).h(px(22.0)).rounded(px(4.0)).bg(rgb(0x545454))+ .flex().items_center().justify_center().child("Apply"))+ }+}diff --git a/bindings/rust/bench/gpui-bench/src/bin/gpui-settings.rs b/bindings/rust/bench/gpui-bench/src/bin/gpui-settings.rsnew file mode 100644index 0000000..2f331ee--- /dev/null+++ b/bindings/rust/bench/gpui-bench/src/bin/gpui-settings.rs@@ -0,0 +1,17 @@+//! The settings window (common/settings.rs) on gpui 0.2.2.+use gpui::{+ App, AppContext, Bounds, Context, IntoElement, ParentElement, Render, Styled, Window, WindowBounds,+ WindowOptions, div, px, rgb, size,+};++include!("../../../common/settings.rs");++fn main() {+ gpui::Application::new().run(|cx: &mut App| {+ let bounds = Bounds::centered(None, size(px(360.0), px(260.0)), cx);+ cx.open_window(WindowOptions { window_bounds: Some(WindowBounds::Windowed(bounds)), ..Default::default() },+ |_, cx| cx.new(|_| Settings { renders: 0 }))+ .unwrap();+ cx.activate(true);+ });+}diff --git a/bindings/rust/bench/gpui-fast-bench/src/bin/gpui-fast-settings.rs b/bindings/rust/bench/gpui-fast-bench/src/bin/gpui-fast-settings.rsnew file mode 100644index 0000000..7d3bc79--- /dev/null+++ b/bindings/rust/bench/gpui-fast-bench/src/bin/gpui-fast-settings.rs@@ -0,0 +1,17 @@+//! The settings window (common/settings.rs) on gpui-fast.+use gpui::{+ App, AppContext, Bounds, Context, IntoElement, ParentElement, Render, Styled, Window, WindowBounds,+ WindowOptions, div, px, rgb, size,+};++include!("../../../common/settings.rs");++fn main() {+ gpui_platform::application().run(|cx: &mut App| {+ let bounds = Bounds::centered(None, size(px(360.0), px(260.0)), cx);+ cx.open_window(WindowOptions { window_bounds: Some(WindowBounds::Windowed(bounds)), ..Default::default() },+ |_, cx| cx.new(|_| Settings { renders: 0 }))+ .unwrap();+ cx.activate(true);+ });+}diff --git a/bindings/rust/blenderui/examples/bench_app.rs b/bindings/rust/blenderui/examples/bench_app.rsnew file mode 100644index 0000000..ed659fb--- /dev/null+++ b/bindings/rust/blenderui/examples/bench_app.rs@@ -0,0 +1,40 @@+//! Benchmark app (bench/run.py): the shared small UI. Prints "ready" once the+//! first frame is on screen, then idles.++use blenderui::prelude::*;++struct Bench {+ ready: bool,+}++impl Render for Bench {+ fn render(&mut self, window: &mut Window, _: &mut Context<Self>) -> impl IntoElement {+ if !self.ready {+ if window.presented_frames() > 0 {+ self.ready = true;+ println!("ready");+ } else {+ window.request_animation_frame(); // render once more after the first present+ }+ }+ div().styled().flex().flex_col().gap_2().p_3()+ .child(span().child("Settings"))+ .child(input().value("Cube"))+ .child(label().child(input().input_type("checkbox").checked(true)).child(" Shadows"))+ .child(input().input_type("range").min(0.0).max(10.0))+ .child(button().child("Apply"))+ }+}++fn main() {+ let opts = WindowOptions {+ window_bounds: Some(WindowBounds::Windowed(Bounds {+ origin: point(px(100.0), px(100.0)),+ size: size(px(360.0), px(260.0)),+ })),+ ..Default::default()+ };+ Application::new().run(move |cx: &mut App| {+ cx.open_window(opts, |_, cx| cx.new(|_| Bench { ready: false })).unwrap();+ });+}diff --git a/bindings/rust/blenderui/examples/hello.rs b/bindings/rust/blenderui/examples/hello.rsindex 0300254..4b6eb6d 100644--- a/bindings/rust/blenderui/examples/hello.rs+++ b/bindings/rust/blenderui/examples/hello.rs@@ -23,7 +23,7 @@ struct Hello;impl Render for Hello {fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {rsx! {- <body styled m-0 p-6 min-h-screen flex flex-col gap-4 bg-zinc-900 text-white>+ <body m-0 p-6 min-h-screen flex flex-col gap-4 bg-zinc-900 text-white><h1 text-2xl font-bold>"Hello, BUI"</h1><counter label="Clicks" /><input type="range" min={0.0} max={10.0} />