パフォーマンス比較
JavaScriptとパフォーマンス比較
http://jsdo.it/demouth/n3n6
/**
* Copyright demouth ( http://wonderfl.net/user/demouth )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bA1P
*/
package {
import flash.display.Graphics;
import flash.events.Event;
import flash.display.Sprite;
import net.hires.debug.Stats;
import com.bit101.components.NumericStepper;
public class FlashTest extends Sprite {
protected var numParticles:int=1000;
public function FlashTest() {
// write as3 code here..
this.stage.frameRate=60;
this.init();
}
protected function init():void{
var stepper:NumericStepper = new NumericStepper(this, 0, 0, this.numChangeHandler);
stepper.value=this.numParticles;
stepper.x=100;
stepper.step=100;
this.addChild(new Stats());
this.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
}
private function enterFrameHandler(event:Event):void{
var g:Graphics=this.graphics;
var i:int=0,l:int=this.numParticles;
var w:int=this.stage.stageWidth, h:int=this.stage.stageHeight;
g.clear();
for(;i<l;i++){
g.beginFill(0);
g.drawCircle(Math.random()*w,Math.random()*h,1);
g.endFill();
}
}
private function numChangeHandler(event:Event):void{
this.numParticles = event.currentTarget.value;
}
}
}