Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

性能测试

huliangjie edited this page Jul 24, 2020 · 1 revision

unity-jsb/xlua/ilruntime

TODO 粗略测试. 后续换成更严谨的测试代码用例.

unity-jsb ilruntime(release) xlua
纯脚本调用 18ms 290ms TODO
值类型交互调用 29ms 37ms TODO
let n = 10000;
let Vector3 = UnityEngine.Vector3;
let sw1 = Date.now();
for (let i = 0; i < n; i++) {
    let v1 = new Vector3(i, i, i);
    let v2 = new Vector3(i, i, i);
    // @ts-ignore
    let v3 = v1 + v2;
}
console.log("Vector3+", Date.now() - sw1);
class V3 {
    x: number;
    y: number;
    z: number;
    constructor(x: number, y: number, z: number) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    static add(a: V3, b: V3): V3 {
        return new V3(a.x + b.x, a.y + b.y, a.z + b.z);
    }
}

let n = 10000;
let sw2 = Date.now();
for (let i = 0; i < n; i++) {
    let v1 = new V3(i, i, i);
    let v2 = new V3(i, i, i);
    let v3 = V3.add(v1, v2);
}
console.log("V3+", Date.now() - sw2);
Clone this wiki locally