Hey all. Just wanted to share the little tool I’ve been working on for comparing different scripting functions and their speed. Here’s the link to the WebGL build:
http://cobaltplay.com/unityspeedtest/

Will be good to hear any suggestions to add to it such as ‘foreach vs for loop’ performance, ‘SetParent() vs Instantiate(parentTransform)’ etc. Let me know if you’d like to find which performance is better.
Martin
Watch out for this null-check thing. I don’t remember if this is the case with Transform, but for GameObjects the null comparison is overridden to do a fair bit of extra work, specifically checking whether the object has been destroyed instead of just being null. There have been several posts about people noting that ReferenceEquals is a lot faster than == null
, and using it, but without being aware of the potential consequences of ending up with a non-null-but-destroyed GameObject because ReferenceEquals returned false.
Anyway, comparisons in general via your tool seem reasonable. Just be sure your tooling itself doesn’t introduce overhead that you count against a particular operation. When I’ve done similar things, I’ve found that I needed to run the same test a few times to start getting reliable results.