This document defines expected performance metrics and regression testing procedures for the RobotWin Studio simulation engine.
| Metric | Target | Critical Threshold | Test Method |
|---|---|---|---|
| Frame Time (100 wires) | < 2ms | < 5ms | Unity Profiler: WireRope.SimulateRope() |
| GC Allocations | 0 B/frame | < 100 B/frame | Unity Profiler: Memory Allocator |
| Wire Collision Checks | < 5000/frame | < 20000/frame | Debug counter in ResolveWireCollisions() |
Regression Test:
// Create test scene with 100 wires in 10x10 grid
for (int i = 0; i < 100; i++) {
CreateWire(position: (i % 10) * 0.2f, length: 0.15f);
}
// Run for 300 frames, measure average frame time| Metric | Target | Critical Threshold | Test Method |
|---|---|---|---|
| Simulation Step Time (100 modules) | < 0.5ms | < 2ms | Profiler: SimulateStep() |
| Determinism | 100% reproducible | Must pass | Record/replay trace comparison |
| Memory Footprint (per module) | < 2KB | < 5KB | Memory snapshot diff |
Regression Test:
// Create 100 hardware modules with varying thermal loads
// Run deterministic simulation for 10000 steps
// Compare trace with golden reference file| Metric | Target | Critical Threshold | Test Method |
|---|---|---|---|
.ToList() calls in hot paths |
0 | 0 | Static analysis + code review |
| UI Update GC Allocations | < 1KB/frame | < 5KB/frame | Profiler: LateUpdate() |
- Fixed Timestep: All physics simulation must use
Time.fixedDeltaTime - Seeded RNG: All random number generation must use deterministic seeds
- Replay Consistency: Recorded sessions must replay identically on different machines
// 1. Record Session
RecordSession(seed: 12345, duration: 60s);
// 2. Replay on Machine A
var traceA = ReplaySession(recording, machine: "DevBox");
// 3. Replay on Machine B
var traceB = ReplaySession(recording, machine: "CI-Server");
// 4. Compare Traces (bit-exact match required)
Assert.Equal(traceA.StateHashes, traceB.StateHashes);- No compiler warnings
- Static analysis: No new
.ToList()in performance-critical files - Unit tests pass (< 5 seconds)
- Integration tests pass (< 30 seconds)
- Profiler smoke test: 100 wires @ 60 FPS
- Memory leak detection: 5 minute stress test
- Full determinism validation suite
- Thermal stress test: 1000 modules for 1 hour
- Replay regression: Compare with golden traces
- Performance benchmarks: Generate trend charts
Trigger alerts if:
- Frame time increases by > 20% compared to baseline
- GC allocations increase by > 50%
- Any determinism test fails
Wire System (100 wires):
- Frame Time: 1.2ms (min: 0.8ms, max: 2.1ms)
- GC Allocations: 0 B/frame
- Collision Checks: 2400/frame (with spatial grid)
Hardware Modules (100 modules):
- Step Time: 0.3ms
- Determinism: PASS (10000 steps validated)
- Load test scene with 200+ wires - verify no stuttering
- Record 10-minute session, replay on different machine - verify exact match
- Thermal simulation: Verify components fail at correct temperatures
- Visual inspection: Wire physics looks natural (sag, collision avoidance)
// BAD: Allocates array every frame
var hits = Physics.OverlapSphere(...);
// GOOD: Reuse static buffer
int count = Physics.OverlapSphereNonAlloc(..., buffer);
// BAD: LINQ allocation in hot path
var boards = circuit.Components.Where(...).ToList();
// GOOD: Direct iteration
foreach (var comp in circuit.Components) {
if (IsBoardType(comp)) { ... }
}- Open Unity Profiler (Window > Analysis > Profiler)
- Enable Deep Profiling for one frame
- Identify:
- Methods taking > 1ms
- GC.Alloc spikes
- Physics.Simulate time
- Take memory snapshot at startup
- Run simulation for 5 minutes
- Take second snapshot
- Compare: Look for leaked objects or growing collections
- Enable verbose logging:
Debug.Logstate hashes every 100 frames - Compare logs from two replay sessions
- Binary search: Find first frame where divergence occurs
- Inspect: Check for
UnityEngine.Randomusage or floating point drift
For performance regressions or questions: [File an issue with "Performance" label]