summaryrefslogtreecommitdiff
path: root/gui/bench/redraw.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-13 01:24:16 -0300
committerGabriel Schneider <[email protected]>2026-11-13 01:34:46 -0300
commit5a40dca5adb6e9e650f55f3ec6f254a13bf50493 (patch)
tree5fdffebd75ed3fbac1eae5dec0a3f2d491450342 /gui/bench/redraw.py
parent4b4113a0217ee27c78e7efddb66ff5a455d49083 (diff)
downloadcomputeranim-5a40dca5adb6e9e650f55f3ec6f254a13bf50493.tar.gz
computeranim-5a40dca5adb6e9e650f55f3ec6f254a13bf50493.zip
debugger: align source and add rich Vim-style navigation
Diffstat (limited to 'gui/bench/redraw.py')
-rw-r--r--gui/bench/redraw.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/gui/bench/redraw.py b/gui/bench/redraw.py
new file mode 100644
index 0000000..84c1314
--- /dev/null
+++ b/gui/bench/redraw.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+"""Estimate steady GUI redraw cost by subtracting matched short and long runs."""
+import argparse
+import json
+from pathlib import Path
+import statistics
+import subprocess
+import tempfile
+import time
+
+ROOT = Path(__file__).resolve().parents[2]
+p = argparse.ArgumentParser(description=__doc__)
+p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui')
+p.add_argument('--c', type=Path, required=True)
+p.add_argument('--v8', type=Path, required=True)
+p.add_argument('--out', type=Path, default=Path('/tmp/ztrace-gui-redraw-ui.json'))
+a = p.parse_args()
+results = {}
+with tempfile.TemporaryDirectory(prefix='ztrace-redraw-') as directory:
+ work = Path(directory)
+ for name, recording in [('c', a.c), ('v8', a.v8)]:
+ samples = {30: [], 330: []}
+ for _ in range(3):
+ for count in samples:
+ script = work / 'draw.script'
+ script.write_text(f'console open {recording.resolve()}\nframes {count}\n')
+ start = time.perf_counter_ns()
+ subprocess.run([str(a.gui.resolve()), '--headless', '--fresh', '--state', str(work / 'draw.state'),
+ '--script', str(script)], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True)
+ samples[count].append((time.perf_counter_ns() - start) / 1e6)
+ results[name] = dict(elapsed_ms=samples,
+ incremental_frame_ms=(statistics.median(samples[330]) - statistics.median(samples[30])) / 300)
+ print(name, json.dumps(results[name]), flush=True)
+a.out.write_text(json.dumps(results, indent=2) + '\n')