Optimization test AS3 - Tween library performances 1 | September 4th, 2008
Today’s topic is Tweening library for ActionScript3. I did a comparison between Tweener (v1.31.71), TweenLite (v8.15) and gTween (Beta2). Correct me if I’m wrong, but as far as I know all of these 3 libraries share the same basic functionality such as easing, on complete function caller, delay, time, etc. I also tried to include GoASAP in this comparison, but decided to exclude it because this one is not meant to work right out of box. It has a lot of customizable properties, but just to get a simple tweening working I would have to write about 10 lines of code (as opposed to 1 or 2) with it’s own update function, which wouldn’t be a fair comparison with the rest. In another word, the performance of GoASAP strongly depends on how the user writes its code. Enough intro, let’s get into action.
I tested the performance by placing N numbers boxes and applying looped linear Tweening on coordinates (x, y) and scaling, simultaneously. Let’s start with file size compareson.
Compiled file size (my code + Tween library)
Base file size without Tween Library: 2.8kb
Tweener: 17.4kb (+14.6kb)
TweenLite: 7.4kb (+4.6kb)
gTween: 9.4kb (+6.6kb)
Here you can see that TweenLite and gTween are significantly smaller than Tweener. Next up is performance.
Average frames per second (500 boxes)
Tweener: 19.8fps (+0)
TweenLite: 25.35fps (+5.55fps)
gTween: 20.9fps (+1.1fps)
Average frames per second (1000 boxes)
Tweener: 8.6fps (+0)
TweenLite: 13.2fps (+4.6fps)
gTween: 10.5fps (+1.9fps)
Once again, TweenLite tops with average of +5fps compared to Tweener. Tweener used to be my favorite tweening library but now is the time is to switch over to TweenLite. gTween also came pretty close and is significantly better than Tweener. Mind you, it is still in beta2 stage so there is still a lot potential for improvements. You can view the test app I made below. Click on “switch” button at top left to switch through tweening libraries.
Warning: this may be memory/CPU intensive for some computers. It has a potential to crash your browser/computer on slower machines.
If you have any other libraries that you suggest for comparison, please let me know as a comment to this post.
September 5th, 2008 at 10:53 am
Great post, Yohei. I appreciate how you got right to the facts, posted numbers, and made your SWF available.
I’m not sure if you saw it, but I did a somewhat similar speed test with all these engines plus several others including an AS2 version here:
http://blog.greensock.com/tweening-speed-test/
Here’s a bezier speed comparison too:
http://blog.greensock.com/bezier-speed-test/