forked from: 文字列出力(com.actionscriptbible.Exampleクラス)
forked from 文字列出力(com.actionscriptbible.Exampleクラス) (diff: 82)
気になったのでstaticの有無,public,private,の処理速度をくらべるテスト
ActionScript3 source code
/**
* Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/9YeX
*/
// forked from shmdmoto's 文字列出力(com.actionscriptbible.Exampleクラス)
/*
* 気になったのでstaticの有無,public,private,の処理速度をくらべるテスト
*
*/
package {
import com.actionscriptbible.Example;
import flash.utils.*;
public class FlashTest extends Example {
static public var spu:int = 0;
public var pu:int = 0;
private var pr:int = 0;
static public var COUNT:int = 1000000;
public function FlashTest() {
// write as3 code here..
trace( testOutStaticPublic() );
trace( testInStaticPublic() );
trace( testPublic() );
trace( testPrivate() );
trace( testLocal() );
}
private function testInStaticPublic():String
{
spu = 0;
var time:uint = getTimer();
var i:int;
for( i=0; i < COUNT; i++ ){
spu++; spu++; spu++; spu++; spu++;
spu++; spu++; spu++; spu++; spu++;
}
var str:String = "" + + (getTimer() - time);
return "static public :" + str;
}
private function testPublic():String
{
pu = 0;
var time:uint = getTimer();
var i:int;
for( i=0; i < COUNT; i++ ){
pu++; pu++; pu++; pu++; pu++;
pu++; pu++; pu++; pu++; pu++;
}
var str:String = "" + + (getTimer() - time);
return "public :" + str;
}
private function testPrivate():String
{
pr = 0;
var time:uint = getTimer();
var i:int;
for( i=0; i < COUNT; i++ ){
pr++; pr++; pr++; pr++; pr++;
pr++; pr++; pr++; pr++; pr++;
}
var str:String = "" + + (getTimer() - time);
return "private :" + str;
}
private function testLocal():String
{
var lo:int = 0;
var time:uint = getTimer();
var i:int;
for ( i = 0; i < COUNT; i++ ) {
lo++; lo++; lo++; lo++; lo++;
lo++; lo++; lo++; lo++; lo++;
}
var str:String = "" + + (getTimer() - time);
return "local :" + str;
}
}
}
import flash.utils.*;
function testOutStaticPublic():String
{
FlashTest.spu = 0;
var time:uint = getTimer();
var i:int;
for( i=0; i < FlashTest.COUNT; i++ ){
FlashTest.spu++; FlashTest.spu++; FlashTest.spu++; FlashTest.spu++; FlashTest.spu++;
FlashTest.spu++; FlashTest.spu++; FlashTest.spu++; FlashTest.spu++; FlashTest.spu++;
}
var str:String = "" + + (getTimer() - time);
return "static public(out) :" + str;
}