Performance Relational Components Performance - Ambiguous-Interactive/unity-helpers GitHub Wiki
Relational component attributes ([SiblingComponent], [ParentComponent], [ChildComponent]) remove repetitive GetComponent* code. These benchmarks quantify the runtime cost of calling Assign*Components for common field shapes (single component, array, List<T>, and HashSet<T>) against hand-written lookups.
Numbers below are grouped by operating system. A section reading pending means nobody has run this suite on that platform, not that the attributes are slow there.
Parent and child queries use pooled typed buffers. A buffer containing Component appends through List<Component>.AddRange; buffers containing derived components retain typed enumeration. A List<DerivedComponent> does not implement ICollection<Component>, so passing it to AddRange misses the bulk-copy path and boxes its enumerator. Both transfer paths preserve query order and existing destination entries. The benchmark tables below predate this transfer change.
Last updated 2026-09-14 05:38 UTC on Windows 11 (10.0.26200).
Numbers capture repeated Assign*Components calls for one second per scenario.
Higher operations per second are better.
| Scenario | Relational Ops/s | Manual Ops/s | Rel/Manual | Iterations |
|---|---|---|---|---|
| Parent - Single | 1,239,795 | 10,018,690 | 0.12x | 1,240,000 |
| Parent - Array | 746,056 | 4,764,392 | 0.16x | 750,000 |
| Parent - List | 802,040 | 7,396,326 | 0.11x | 810,000 |
| Parent - HashSet | 777,660 | 3,955,524 | 0.20x | 780,000 |
| Child - Single | 665,079 | 5,341,149 | 0.12x | 670,000 |
| Child - Array | 293,349 | 3,229,543 | 0.09x | 300,000 |
| Child - List | 285,215 | 3,783,105 | 0.08x | 290,000 |
| Child - HashSet | 300,276 | 2,001,901 | 0.15x | 310,000 |
| Sibling - Single | 4,636,847 | 28,450,407 | 0.16x | 4,640,000 |
| Sibling - Array | 1,242,712 | 3,361,155 | 0.37x | 1,250,000 |
| Sibling - List | 1,339,612 | 4,176,273 | 0.32x | 1,340,000 |
| Sibling - HashSet | 1,260,522 | 2,255,225 | 0.56x | 1,270,000 |
Pending: run the relational component benchmark suite on macOS to capture results.
Pending: run the relational component benchmark suite on Linux to capture results.
Pending: run the relational component benchmark suite on the target platform to capture results.
Run RelationalComponentBenchmarkTests.Benchmark from Unity's Test Runner. It rewrites the section matching the operating system it ran on and leaves the others alone.