Home Contact

[September 26, 2005]

The flash.geom.Point Class is Slow

Filed under: ActionScript — @ 3:01 pm

… at least on my system. This past week I decided to upgrade my flocking simulation project to use the Flash 8 Point class. I had a 2D coordinate class, as I’m sure many people do, and I expected I’d retire it. But it turned out that changing over to flash.geom.Point slowed the app down considerably.

Here you can download a MyPoint class that conforms to the flash.geom.Point API, and the PointTest class I used to compare its performance to that of flash.geom.Point. I built the program with MTASC and with Flash 8. Both swfs had the same dimensions and fps.

Windows XP Pro, Pentium 4 2.80 GHz, 2GB RAM, Flash 8 standalone player

Average times in milliseconds: 5 runs of each swf, iterations = 10000
(Equals test: 10000 iterations with equal Points, 10000 iterations with unequal Points)

		swf built by:	MTASC			Flash 8
				------------		------------
		Point class:	flash	mine		flash	mine

TEST
Interpolate			520	349		524	357
Distance			724	154		711	166
Polar				557	363		548	379
Constructor			249	185		282	180
Clone				412	285		441	309
Offset				85	92		98	91
Equals				316	256		239	254
Subtract			420	308		465	346
Add				448	322		493	344
Normalize			281	263		272	271
ToString			147	152		173	170

Contents copyright © Alan Shaw 2005-2008

25 queries. 0.209 seconds. Powered by WordPress version 2.5.1