和slua真机性能对比,我就直接用lua的测试代码了
[Lua] 纯文本查看 复制代码
function test1()
local transform = cube.transform
local start = os.clock()
for i=1,200000 do
transform.position=transform.position
end
print("test1/lua " .. (os.clock() - start));
end
function test2()
local transform=cube.transform
local start = os.clock()
for i=1,200000 do
transform:Rotate(Vector3.up, 90)
end
print("test2/lua " .. (os.clock() - start));
end
function test3()
local start = os.clock()
for i=1,2000000 do
local v = Vector3(i,i,i)
Vector3.Normalize(v)
end
print("test3/lua " .. (os.clock() - start));
end
function test4()
local t = cube.transform
local v = Vector3.one
local start = os.clock()
for i=1,200000 do
local v = GameObject()
end
print("test4/lua " .. (os.clock() - start));
end
[Actionscript3] 纯文本查看 复制代码 public function Test1():void
{
var d:DateTime = DateTime.now;
var transform:Transform = cube.transform;
for (var i:int = 0; i < 200000 ; i++)
{
transform.position = transform.position;
}
trace( TimeSpan (DateTime.now-d).totalMilliseconds );
}
public function Test2():void
{
var d:DateTime = DateTime.now;
var transform:Transform = cube.transform;
for (var i:int = 0; i < 200000 ; i++)
{
transform.rotate____(Vector3.up, 90);
}
trace( TimeSpan (DateTime.now-d).totalMilliseconds );
}
public function Test3():void
{
var d:DateTime = DateTime.now;
for (var i:int = 0; i < 2000000 ; i++)
{
var v:Vector3 =new Vector3(i,i,i)
Vector3.normalize(v)
}
trace( TimeSpan (DateTime.now-d).totalMilliseconds );
}
public function Test4():void
{
var d:DateTime = DateTime.now;
for (var i:int = 0; i < 200000; i++)
{
var v:GameObject = GameObject.constructor_();
}
trace( TimeSpan (DateTime.now-d).totalMilliseconds );
}
|