• xlua、tolua性能对比


      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 .. "
    reset transform.position
    " .. "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 .. "
    transform.rotate
    " .. "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 .. "
    vector3.normalize
    " .. "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 .. "
    new gameobject
    " .. "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 .. "
    reset component attributes
    " .. "test5/lua " .. (os.clock() - start))
    end
    
    main()
    test1()
    test2()
    test3()
    test4()
    test5()
  • 相关阅读:
    Oracle Scheduler Postponed job
    MySQL字符集问题
    LogMiner的一个案例
    Oracle Scheduler NLS_ENV
    ORA01555的模拟
    在线重定义 Oracle Redefinition
    MySQL Proxy 读写分离
    SQL判断分段的连续值
    基础复习之.net中new关键字的用法
    VB与C#相互转换
  • 原文地址:https://www.cnblogs.com/hghhe/p/12910869.html
Copyright © 2020-2023  润新知