Tuesday, May 29, 2012
Monday, May 28, 2012
Kroolz
As recently promised, "Krool Joolz" has made a comeback on the iOS platform as "Kroolz". Get it here, it's Free!
Monday, May 07, 2012
Micro Optimisation in Unity3D
NGUI caches the transform component in a member variable called mTrans, to optimise speed of access. I think this is UGLY, so I decided to do some benchmarks to see if the ugliness is worth the performance increase.
In short, the answer is NO.
My tests showed that using a local variable is always as fast as using a member variable, and usually faster.
Here are some typical results.
They show that caching and accessing the target reference is twice as fast as just using the reference. They also show that assigning to a local variable and using that variable for access is usually even faster than a member variable.
This is the code I used for benchmarking.
In short, the answer is NO.
My tests showed that using a local variable is always as fast as using a member variable, and usually faster.
Here are some typical results.
Cached: Time elapsed: 00:00:04.8086550 Uncached: Time elapsed: 00:00:09.1058490 Local: Time elapsed: 00:00:04.7870590
They show that caching and accessing the target reference is twice as fast as just using the reference. They also show that assigning to a local variable and using that variable for access is usually even faster than a member variable.
This is the code I used for benchmarking.
using UnityEngine; using System.Collections; public class Benchmark : MonoBehaviour { Transform cachedTransform; void Start () { cachedTransform = transform; TestCached(); TestUncached(); TestLocal(); } void TestUncached() { var stopwatch = new System.Diagnostics.Stopwatch (); stopwatch.Start (); for (int i = 0; i < 100000000; i++) { var p = transform.position; } stopwatch.Stop (); Debug.Log (string.Format("Uncached: Time elapsed: {0}", stopwatch.Elapsed)); } void TestCached() { var stopwatch = new System.Diagnostics.Stopwatch (); stopwatch.Start (); for (int i = 0; i < 100000000; i++) { var p = cachedTransform.position; } stopwatch.Stop (); Debug.Log (string.Format("Cached: Time elapsed: {0}", stopwatch.Elapsed)); } void TestLocal() { var stopwatch = new System.Diagnostics.Stopwatch (); stopwatch.Start (); var t = transform; for (int i = 0; i < 100000000; i++) { var p = t.position; } stopwatch.Stop (); Debug.Log (string.Format("Local: Time elapsed: {0}", stopwatch.Elapsed)); } }
Saturday, May 05, 2012
Rendering HTML
Rendering HTML in Unity3D sure is... tricky. It would seem simple enough, but page/text layout algorithms can certainly be challenging, even when supporting only a subset of HTML.
Subscribe to:
Posts (Atom)
Popular Posts
-
These are the robots I've been working on for the last 12 months. They each weigh about 11 tonnes and have a 17 meter reach. The control...
-
I get many confused emails from people trying to get UniWeb to work in the Unity WebPlayer. It works, but you have to set things up correctl...
-
So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along. ...
-
Often, when building a game, you need to test if objects are colliding. The objects could be spaceships, rocks, mouse pointers, laser beams....
-
I went to the pulse expo this evening, where one of the speakers mentioned that Ubisoft are in town (Perth, Western Australia), looking to...
-
I'm about to release a Tech Tree editor tool for Unity. To test usability and work out how improve the interface, I used it to buil...
-
I've been working on something new. I get a lot of projects where I have to add multiuser functionality. Finally I've made the jump ...
-
I decided to double check my assumptions about Stackless and the GIL on a multicore machine, using the same example provided by David Beazl...
-
In my spare time this week, instead of building spaceships, playing games or even drinking beer... I will make a game for the Apple App Stor...
-
In the 7 years I've been actively involved in web development, I have never seen any of my peers bother implementing proper controls to ...