Tag: Performance Optimization

Unity Debug Diaries

Performance Myth Busters: Variable Allocation

In Unity Performance Myth Busters I take an assumption and check if it’s still valid or just programming superstition. There is nothing like proof to end an argument or inform a decision. Plus, there is nothing like being humbled by a junior dev because you did not do your homework! Today, I want to chat about local variable usage in an update loop. So, you have all seen a loop like this:

private void Update(){
Vector3 eularRotation = assetToRotate.localEulerAngles;
eularRotation.y += Time.smoothDeltaTime * 10f;
assetToRotate.localEulerAngles = eularRotation;
}

So I created a project to test my theories. I am running on a MacBook Pro, Unity 2017.3.1f1, compiling for Mac standalone. At first, I run it in the editor with the profiler and we are getting the typical GC sawtooth curves. But as we know, profiling in the editor is a lie. Profiling a build, GC is a flat line! No change what so ever. That’s great news but is it only that the change is so tiny, we cant notice? Possible.

Next, I ran 64 instances of my test… and that was a flat line too. Before I bust this myth though, I want to make super sure so we are going to try 100k instances… because I can… and for science. Yea, that was a little heavy-handed. Let’s try 20k.

So after 20k instances of the above code, I can safely say local variable assignments does not generate garbage. Solid like a rock and myth busssssted!

All my Performance…




LA Unity User Group with Zhenping Guo from Unity China

At last night’s Los Angeles Unity User Group, we had the privilege to listen to Zhenping Guo from Unity China. He gave us a great double session, first about performance optimization in Unity and secondly about Unity China and their service offering. Yes, thats right, service offering. Unity is not only committed to making a great tool but its committed to providing ways to bring your creation to the world.. and in this case, that part of the world is China! China’s mobile market is booming and the numbers are staggering in comparison to most other territories. The same goes for Unity. One third of all the unity users in the world are in China and that number is growing rapidly. Why you might ask? Well because of the size of the pie, and Unity is now helping you to get a slice without any cost to you! Thats right, you give em your game, and they do all the work to get it into the Chinese market for a small percentage of profit. I am sure I am simplifying the process but if that at all sounds enticing, make sure to hit Zhenping Guo up for more info.

I also mentioned Text Mesh Pro. For anyone interested in this truly next generation text solution for Unity, check it out here on the Asset Store, or follow Stephan, the author on twitter.

Below are the slides from his great back to back session. If you prefer to download them,…