跳到主要内容

PuerTS的性能表现

从我们的测试结果上看,极限情况下,即xLua(Lua53)使用wrapper,PuerTS(v8_9.4)使用xIl2cpp模式同时生成wrapper:

  • 跨语言性能:
    • 在安卓上,普洱的跨语言性能是xlua的2倍左右
    • ios上和xlua持平(无参或者参数为基本数据类型时稍慢,参数为对象时稍快)。
  • 自身执行性能
    • 由于lua53没有JIT,安卓上执行性能PuerTS完胜xLua。甚至PuerTS不比C#差多少。
    • ios下大家都没有JIT,PuerTS与xLua持平。

测试基准项目由社区大佬throw-out的项目修改而成,参见该fork

数据展示

  • Puer S 代表不使用xIl2cpp模式,且生成了StaticWrapper时的数据
  • Puer X R 代表使用xIl2cpp模式,但没有生成xIl2cpp StaticWrapper时的数据
  • Puer X S 代表使用xIl2cpp模式,且生成了xIl2cpp Staticrapper时的数据
  • 时间单位是ms

受环境影响以下数据可能会有略微误差。

关注跨语言数据时,尤其对于结构体的case,可减去C#的耗时(即API本身耗时)来考虑。

这个页面上线以来,数据也发生过变动,原因:https://github.com/throw-out/PerformanceTesting/pull/2https://github.com/Tencent/xLua/commit/899175ef946bb8f9d3e70d425cb875d7510adc82

安卓所有数据 (Vivo Neo6SE)

MethodStaticCallcsharpxLuapuer Spuer X Rpuer X S
void Payload();×2000000.034.730.042.024.0
void Payload();2000000.021.323.020.09.0
void Payload(int);2000000.018.130.032.024.0
void Payload(int);×2000000.037.036.056.029.0
void Payload(int, int, float);2000000.037.438.062.016.0
void Payload(int, int, float);×2000000.056.432.068.016.0
float Payload(int, int, float);2000000.330.125.072.036.0
float Payload(int, int, float);×2000000.341.430.095.025.0
float Payload();2000000.217.829.034.027.0
float Payload();×2000000.238.333.059.014.0
Quaternion Payload(Transform);20000024.387.393.058.046.0
Quaternion Payload(Transform);×20000024.2100.090.060.046.0
Quaternion Payload(Transform, float, float, float);20000043.1102.298.085.048.0
Quaternion Payload(Transform, float, float, float);×20000043.0112.699.088.049.0
Quaternion Payload(Transform, Vector3);20000024.2103.7152.072.047.0
Quaternion Payload(Transform, Vector3);×20000024.3118.3149.073.049.0
fibonacci(40);1640.820771.11899.01888.01887.0
payload(): number // ScriptCallScript200000000245.39350.3183.0182.0182.0

ios所有数据 (iPhone XsMax)

MethodStaticCallcsharpxLuapuer Spuer X Rpuer X S
void Payload();×2000000.010.228.027.024.0
void Payload();2000000.025.834.034.026.0
void Payload(int);2000000.010.727.030.022.0
void Payload(int);×2000000.021.230.033.023.0
void Payload(int, int, float);2000000.012.334.047.026.0
void Payload(int, int, float);×2000000.023.936.050.028.0
float Payload(int, int, float);2000000.010.443.072.034.0
float Payload(int, int, float);×2000000.032.143.073.036.0
float Payload();2000000.311.029.046.025.0
float Payload();×2000000.316.431.049.027.0
Quaternion Payload(Transform);20000034.068.799.072.062.0
Quaternion Payload(Transform);×20000034.983.5100.074.067.0
Quaternion Payload(Transform, float, float, float);20000063.378.5108.0101.083.0
Quaternion Payload(Transform, float, float, float);×20000063.689.7107.0102.075.0
Quaternion Payload(Transform, Vector3);20000035.978.8159.088.064.0
Quaternion Payload(Transform, Vector3);×20000034.895.8168.088.069.0
fibonacci(40);1500.820580.617513.017315.017474.0
payload(): number // ScriptCallScript200000000282.39093.210896.010502.010851.0