色んな真偽の判定の仕方
環境によって大きな違いが出たりはするかな
♥0 |
Line 201 |
Modified 2015-02-18 00:59:01 |
MIT License
archived:2017-03-20 08:06:02
ActionScript3 source code
/**
* Copyright yasurageruheya ( http://wonderfl.net/user/yasurageruheya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jQxN
*/
package {
import flash.display.Sprite;
import flash.events.Event;
[SWF(frameRate="60")]
public class FlashTest extends Sprite {
public const LOOP:int = 2000000;
public var initialized:Initialized = new Initialized();
public var notInitialize:Initialized;
public var instanceFalse:False = new False();
public var int1:Int1 = new Int1();
public var int0:Int0 = new Int0();
public var index:int = 0;
public function FlashTest() {
// write as3 code here..
stage.frameRate = 1000;
var i:int = 0;
addChild(new Tester("accessInstance", accessInstance)).y = (i++) * 20;
addChild(new Tester("acceccInstance2", acceccInstance2)).y = (i++) * 20;
addChild(new Tester("acceccBooleanTrue", acceccBooleanTrue)).y = (i++) * 20;
addChild(new Tester("acceccBooleanTrue2", acceccBooleanTrue2)).y = (i++) * 20;
addChild(new Tester("accessNullInstance", accessNullInstance)).y = (i++) * 20;
addChild(new Tester("accessNullInstance2", accessNullInstance2)).y = (i++) * 20;
addChild(new Tester("accessBooleanFalse", accessBooleanFalse)).y = (i++) * 20;
addChild(new Tester("accessBooleanFalse2", accessBooleanFalse2)).y = (i++) * 20;
addChild(new Tester("accessInt0false", accessInt0false)).y = (i++) * 20;
addChild(new Tester("accessInt0true", accessInt0true)).y = (i++) * 20;
addChild(new Tester("accessInt1true", accessInt1true)).y = (i++) * 20;
addChild(new Tester("accessInt1false", accessInt1false)).y = (i++) * 20;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
if (index >= Tester.testers.length)
{
index = 0;
Tester.counter++;
}
Tester.testers[index].test();
index++;
}
private function accessInstance():void
{
var i:int = LOOP;
while (i--)
{
if (initialized) { }
else{}
}
}
private function acceccInstance2():void
{
var i:int = LOOP;
while (i--)
{
if (!initialized) { }
else { }
}
}
private function acceccBooleanTrue():void
{
var i:int = LOOP;
while (i--)
{
if (initialized.isInitialized) { }
else{}
}
}
private function acceccBooleanTrue2():void
{
var i:int = LOOP;
while (i--)
{
if (!initialized.isInitialized) { }
else{}
}
}
private function accessNullInstance():void
{
var i:int = LOOP;
while (i--)
{
if (notInitialize) { }
else{}
}
}
private function accessNullInstance2():void
{
var i:int = LOOP;
while (i--)
{
if (!notInitialize) { }
else{}
}
}
private function accessBooleanFalse():void
{
var i:int = LOOP;
while (i--)
{
if (instanceFalse.isTrue) { }
else{}
}
}
private function accessBooleanFalse2():void
{
var i:int = LOOP;
while (i--)
{
if (!instanceFalse.isTrue) { }
else{}
}
}
private function accessInt0true():void
{
var i:int = LOOP;
while (i--)
{
if (!int0.int0) { }
else{}
}
}
private function accessInt0false():void
{
var i:int = LOOP;
while (i--)
{
if (int0.int0) { }
else{}
}
}
private function accessInt1true():void
{
var i:int = LOOP;
while (i--)
{
if (int1.int1) { }
else{}
}
}
private function accessInt1false():void
{
var i:int = LOOP;
while (i--)
{
if (!int1.int1) { }
else{}
}
}
}
}
import flash.text.TextField;
import flash.utils.getTimer;
class Tester extends TextField
{
public static var counter:int = 1;
public static var loop:int = 1;
public static var testers:Vector.<Tester> = new Vector.<Tester>();
public var totalTime:Number = 0;
public var func:Function;
public var funcName:String;
public function test():void
{
var time:int = getTimer();
var i:int = loop;
while (--i > -1)
{
func();
}
totalTime += getTimer() - time;
this.text = funcName + " average : " + (totalTime / counter) + ".ms";
}
public function Tester(funcName:String, func:Function)
{
this.funcName = funcName;
this.func = func;
this.autoSize = "left";
testers[testers.length] = this;
}
}
class Initialized
{
public var isInitialized:Boolean = false;
public function Initialized()
{
isInitialized = true;
}
}
class False
{
public var isTrue:Boolean = false;
public function False(){}
}
class Int1
{
public var int1:int = 1;
public function Int1(){}
}
class Int0
{
public var int0:int = 0;
public function Int0(){}
}