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...
-
This hard-to-see screenshot is a Generic Node Graph Editing framework I'm building. I'm hoping it can be used for any kind of node...
-
So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along. ...
-
MiddleMan: A Pub/Sub and Request/Response server in Go. This is my first Go project. It is a rewrite of an existing Python server, based o...
-
Why would I ask that question? Python 3 has been available for some time now, yet uptake is slow. There aren't a whole lot of packages i...
-
It is about 8 degrees C this morning. So cold, especially when last week we had high twenties. To help solve the problem, a friend suggeste...
-
After my last post, I decided to benchmark the scaling properties of Stackless, Kamaelia, Fibra using the same hackysack algorithm. Left axi...
-
I'm now using bzr instead of svn. I'm pushing my repositories to: http://exactlysimilar.org/bzr/ I'm also auto publishing docume...
-
Possibly slightly more correct lighting. The rim light is now only applied in the direction of the sun, rather than being purely based on vi...
-
I've just read a newspaper article (courtesy of Kranzky ) from WA Business News documenting the malfeasance, gross negligence and misc...