Skip to content

bug: the walt file of wasm spended more time than js #184

@CBulFel

Description

@CBulFel

`

walt:

export function SUM(n: i32): i32 {

let sum: i32 = 0;

let i: i32 = 0;

while(i < n) {
    sum = sum + i;
    i = i + 1;
}

return sum;

}

SUMWalt().then(wasmModule => {
const begin = Date.now()
console.log('wasm begin: ', begin)
console.log('wasm:', wasmModule.instance.exports.SUM(999999999)) // 1
console.log('wasm end: ', Date.now() - begin)
})

js:

function SUM(n) {

let sum = 0;

let i = 0;

while(i < n) {
    sum = sum + i;
    i++;
}

return sum;

}

const begin = Date.now()
console.log('js begin: ', begin)
console.log('js: ', SUM(999999999)) // 1
console.log('js end: ', Date.now() - begin)

`

result:

the SUM funtion return value is not the same, and the wasm time more than js time.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions