Commit 298c2cf
committed
Add performance timing metrics for React reconciliation and ImGui rendering
Implement comprehensive performance monitoring system that measures and displays timing statistics:
**JavaScript Measurements:**
1. React Reconciliation (lib/react-imgui-reconciler/):
- Measure in host-config.js prepareForCommit → resetAfterCommit
- Captures actual reconciliation work (component execution + React diffing + commit)
- Calculate statistics in perf-stats.js:
* Moving average from last 30 samples
* Time-windowed max (last 5 seconds)
- Module-scope variables for efficiency
2. ImGui Rendering (lib/imgui-unit/renderer.js):
- Measure tree traversal and ImGui FFI calls
- Runs every frame
- Export timing via globalThis.perfMetrics
**C++ Display (lib/imgui-runtime/imgui-runtime.cpp):**
- Read metrics from JavaScript globalThis in update_performance_metrics()
- Calculate EMA for ImGui render time (α=0.1)
- Update display values once per second (prevents blurring)
- Render with Sokol Debug Text at bottom-left corner:
* FPS: 60
* ImGui: 850us (EMA, per frame)
* React: 120/235us (avg/max in microseconds)
**CLAUDE.md Updates:**
- Add development workflow rule: Do not commit before user review and testing1 parent 10ea88b commit 298c2cf
File tree
5 files changed
+145
-3
lines changed- lib
- imgui-runtime
- imgui-unit
- react-imgui-reconciler
5 files changed
+145
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
14 | 26 | | |
15 | 27 | | |
16 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
106 | 115 | | |
107 | 116 | | |
108 | 117 | | |
| |||
192 | 201 | | |
193 | 202 | | |
194 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
195 | 232 | | |
196 | 233 | | |
197 | 234 | | |
| |||
201 | 238 | | |
202 | 239 | | |
203 | 240 | | |
204 | | - | |
| 241 | + | |
205 | 242 | | |
206 | 243 | | |
207 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
208 | 248 | | |
209 | 249 | | |
210 | 250 | | |
| |||
247 | 287 | | |
248 | 288 | | |
249 | 289 | | |
| 290 | + | |
| 291 | + | |
250 | 292 | | |
251 | 293 | | |
252 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
253 | 308 | | |
254 | 309 | | |
255 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| 712 | + | |
| 713 | + | |
712 | 714 | | |
713 | 715 | | |
714 | 716 | | |
| |||
728 | 730 | | |
729 | 731 | | |
730 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
731 | 741 | | |
732 | 742 | | |
733 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
351 | 355 | | |
352 | 356 | | |
353 | 357 | | |
| 358 | + | |
354 | 359 | | |
355 | 360 | | |
356 | 361 | | |
| |||
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
363 | 376 | | |
364 | 377 | | |
365 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments