关于as3性能的问题 Flex
我最近做了一个测试,发现Flex(as3)的计算性能特别差(比java慢了几乎几百倍)。但是,为什么Web视频媒体上Flex却表现不错?求高手讲解讲解!
试验一、1到1亿的求和:
java代码:
public static void main(String[] arg)
{
long begin=new Date().getTime();
int result=0;
for(int i=0;i<=100000000;i++)
{
result+=1;
}
long end=new Date().getTime();
System.out.println("用时:"+(end-begin));
}
protected function button1_clickHandler(event:MouseEvent):void
{
var t1:Number=getTimer();
var count:int=0;
for(var i:int=0;i<100000000;i++)
{
count+=1;
}
var t2:Number=getTimer();
var result:Number=t2-t1;
trace("用时:"+result.toString());
}
private void test()
{
long begin=new Date().getTime();
int i=100000000;
while(i>0)
{
func();
i--;
}
long end=new Date().getTime();
System.out.println("用时:"+(end-begin));
}
private void func()
{
}
protected function button2_clickHandler(event:MouseEvent):void
{
var t1:Number=getTimer();
var i:int=100000000;
while(i>0)
{
func();
i--;
}
var t2:Number=getTimer();
var result:Number=t2-t1;
trace("用时:"+result.toString());
}
private function func():void
{
}