标签:性能 render 脚本 profile cal Fix one ror ado
Unity版本:2018.4.3,mac版
测试平台:都选择android平台, 编辑器下运行
xlua版本:2.1.14
tolua版本:Aug 9, 2019发布版本
测试方法:相同的lua代码,每个测试用例取稳定值
测试结果:
通过上图发现,xlua全面占优啊。附上测试的lua脚本:
if not UnityEngine.GameObject then error("Click Make/All to generate lua wrap file") end local Vector3 = UnityEngine.Vector3 local GameObject = UnityEngine.GameObject local Profiler = UnityEngine.Profiler local Time = UnityEngine.Time local Matrix4x4 = UnityEngine.Matrix4x4 local Texture2D = UnityEngine.Texture2D local Quaternion = UnityEngine.Quaternion local SkinnedMeshRenderer = UnityEngine.SkinnedMeshRenderer function main() print(jit and "jit on" or "jit off, pls run test with luajit") end local cube = GameObject("Script cube") local prefix = jit and "jit on" or "jit off" function test1() local transform = cube.transform local start = os.clock() for i=1,200000 do transform.position=transform.position end print(prefix .. "\nreset transform.position\n" .. "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(prefix .. "\ntransform.rotate\n" .. "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(prefix .. "\nvector3.normalize\n" .. "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(prefix .. "\nnew gameobject\n" .. "test4/lua " .. (os.clock() - start)) end function test5() local v = cube.transform.position local start = os.clock() for i=1,20000 do local v = GameObject() v:AddComponent(typeof(SkinnedMeshRenderer)) local c=v:GetComponent(typeof(SkinnedMeshRenderer)) c.receiveShadows=false end print(prefix .. "\nreset component attributes\n" .. "test5/lua " .. (os.clock() - start)) end main() test1() test2() test3() test4() test5()
标签:性能 render 脚本 profile cal Fix one ror ado
原文地址:https://www.cnblogs.com/hghhe/p/12910869.html