AS3.0在内部做了一些优化,并引入了JIT,但还是有需要争分夺秒的地方。比如游戏的AI等运算量大的算法。
以下列出一些优化公式:(每个公式均测试5次,取平均值,每次循环次数为6000000,单位为ms)
//当x为int时 -x => ~x+1 // 从 134 到 8 -x-1 => ~x //从 154 到 5-(~x) => x+1 //从 130 到 8
在内部,-x有可能被编译为(-1) * x。而~x+1却为inc ~x(inc 为CPU的内部命令,意思是加一)。下面的两个公式就不用解释了。
![[Google]](http://www.google.com/logos/Logo_25wht.gif)
![[Synchronous Space]](http://weihe924stephen.googlepages.com/syncspace-banner.jpg)
![[Creative Commons License]](http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png)
![[Add to Google]](http://buttons.googlesyndication.com/fusion/add.gif)
![[Aggregated by MXNA]](http://weblogs.macromedia.com/mxna/images/mxna88x31.gif)
![[Flex.org]](http://www.flex.org/images/flexorg.gif)
![Validate my Atom 1.0 feed [Valid Atom 1.0]](http://validator.w3.org/feed/images/valid-atom.png)
![Validate my RSS feed [Valid RSS]](http://resource.googlecode.com/files/valid-rss.png)
![[I heart FeedBurner]](http://www.feedburner.com/fb/images/pub/i_heart_fb.gif)
没有评论:
发表评论