Permalink
Browse files

Trying to get new files up

  • Loading branch information...
1 parent 326509a commit 88b0cb489d13b53eefc9dd0c6853a217c5ec53e3 @renaun committed Oct 15, 2010
Showing with 210 additions and 0 deletions.
  1. +70 −0 src/CPUTest.as
  2. +70 −0 src/CPUTestNoCABM.as
  3. +70 −0 src/GPUTestNoCABM.as
View
@@ -0,0 +1,70 @@
+package
+{
+ import flash.desktop.NativeApplication;
+ import flash.display.DisplayObject;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+ import flash.text.TextField;
+
+ public class CPUTest extends Sprite
+ {
+
+ private const squareCount:uint = 1;
+ private var frameCount:int = 0;
+ private var FRAME_TEST_MAX:int = 500;
+ private var startTime:Number;
+
+ public function CPUTest()
+ {
+ super();
+ this.stage.frameRate = 50;
+ this.stage.scaleMode = StageScaleMode.NO_SCALE;
+ this.stage.align = StageAlign.TOP_LEFT;
+ this.stage.addEventListener(MouseEvent.CLICK, onClick);
+ this.addEventListener(Event.DEACTIVATE, onDeactivate);
+ }
+
+ private function onClick(e:MouseEvent):void
+ {
+ startTime = (new Date()).getTime();
+ frameCount = 0;
+ this.addEventListener(Event.ENTER_FRAME, statsHandler);
+ // Create ten of these
+ for (var i:int = 0; i < 10; i++)
+ this.placeSquare(stage.stageWidth*i/10, stage.stageHeight/2);
+ }
+
+ private function statsHandler(event:Event):void
+ {
+ frameCount++;
+ if (frameCount == FRAME_TEST_MAX)
+ {
+ var endTime:Number = (new Date()).getTime();
+ var tf:TextField = new TextField();
+ tf.text = "FPS: " + ((frameCount) /( (endTime - startTime)/1000)).toFixed(2);
+ addChild(tf);
+ }
+ }
+
+ private function onDeactivate(e:Event):void
+ {
+ if (this.numChildren == 0) return;
+ do
+ {
+ this.removeChildAt(0);
+ }
+ while (this.numChildren > 0);
+ }
+
+ public function placeSquare(x:uint, y:uint):void
+ {
+ var s:Square = new Square(this.stage.stageWidth / 2, true);
+ s.x = x;
+ s.y = y;
+ this.addChild(s);
+ }
+ }
+}
View
@@ -0,0 +1,70 @@
+package
+{
+ import flash.desktop.NativeApplication;
+ import flash.display.DisplayObject;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+ import flash.text.TextField;
+
+ public class CPUTestNoCABM extends Sprite
+ {
+
+ private const squareCount:uint = 1;
+ private var frameCount:int = 0;
+ private var FRAME_TEST_MAX:int = 500;
+ private var startTime:Number;
+
+ public function CPUTestNoCABM()
+ {
+ super();
+ this.stage.frameRate = 50;
+ this.stage.scaleMode = StageScaleMode.NO_SCALE;
+ this.stage.align = StageAlign.TOP_LEFT;
+ this.stage.addEventListener(MouseEvent.CLICK, onClick);
+ this.addEventListener(Event.DEACTIVATE, onDeactivate);
+ }
+
+ private function onClick(e:MouseEvent):void
+ {
+ startTime = (new Date()).getTime();
+ frameCount = 0;
+ this.addEventListener(Event.ENTER_FRAME, statsHandler);
+ // Create ten of these
+ for (var i:int = 0; i < 10; i++)
+ this.placeSquare(stage.stageWidth*i/10, stage.stageHeight/2);
+ }
+
+ private function statsHandler(event:Event):void
+ {
+ frameCount++;
+ if (frameCount == FRAME_TEST_MAX)
+ {
+ var endTime:Number = (new Date()).getTime();
+ var tf:TextField = new TextField();
+ tf.text = "FPS: " + ((frameCount) /( (endTime - startTime)/1000)).toFixed(2);
+ addChild(tf);
+ }
+ }
+
+ private function onDeactivate(e:Event):void
+ {
+ if (this.numChildren == 0) return;
+ do
+ {
+ this.removeChildAt(0);
+ }
+ while (this.numChildren > 0);
+ }
+
+ public function placeSquare(x:uint, y:uint):void
+ {
+ var s:Square = new Square(this.stage.stageWidth / 2, false);
+ s.x = x;
+ s.y = y;
+ this.addChild(s);
+ }
+ }
+}
View
@@ -0,0 +1,70 @@
+package
+{
+ import flash.desktop.NativeApplication;
+ import flash.display.DisplayObject;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+ import flash.text.TextField;
+
+ public class GPUTestNoCABM extends Sprite
+ {
+
+ private const squareCount:uint = 1;
+ private var frameCount:int = 0;
+ private var FRAME_TEST_MAX:int = 500;
+ private var startTime:Number;
+
+ public function GPUTestNoCABM()
+ {
+ super();
+ this.stage.frameRate = 50;
+ this.stage.scaleMode = StageScaleMode.NO_SCALE;
+ this.stage.align = StageAlign.TOP_LEFT;
+ this.stage.addEventListener(MouseEvent.CLICK, onClick);
+ this.addEventListener(Event.DEACTIVATE, onDeactivate);
+ }
+
+ private function onClick(e:MouseEvent):void
+ {
+ startTime = (new Date()).getTime();
+ frameCount = 0;
+ this.addEventListener(Event.ENTER_FRAME, statsHandler);
+ // Create ten of these
+ for (var i:int = 0; i < 10; i++)
+ this.placeSquare(stage.stageWidth*i/10, stage.stageHeight/2);
+ }
+
+ private function statsHandler(event:Event):void
+ {
+ frameCount++;
+ if (frameCount == FRAME_TEST_MAX)
+ {
+ var endTime:Number = (new Date()).getTime();
+ var tf:TextField = new TextField();
+ tf.text = "FPS: " + ((frameCount) /( (endTime - startTime)/1000)).toFixed(2);
+ addChild(tf);
+ }
+ }
+
+ private function onDeactivate(e:Event):void
+ {
+ if (this.numChildren == 0) return;
+ do
+ {
+ this.removeChildAt(0);
+ }
+ while (this.numChildren > 0);
+ }
+
+ public function placeSquare(x:uint, y:uint):void
+ {
+ var s:Square = new Square(this.stage.stageWidth / 2, false);
+ s.x = x;
+ s.y = y;
+ this.addChild(s);
+ }
+ }
+}

0 comments on commit 88b0cb4

Please sign in to comment.