Skip to content

Commit

Permalink
run entry function before run exported function
Browse files Browse the repository at this point in the history
Signed-off-by: Su Yihan <[email protected]>
  • Loading branch information
yviansu committed Feb 20, 2024
1 parent 6e4a7a3 commit 8711788
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/validate/run_module/import_object.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,16 @@ function run_wasm_module(wasmFilePath, wasmFuncName, ...funcArgs) {
.then((results) => {
const exports = results.instance.exports;
const exportedFunc = exports[wasmFuncName];
const startTime = performance.now();
const _start = exports._entry;
_start();
const res = exportedFunc(...funcArgs);
const resultElement = document.getElementById('result');
resultElement.innerHTML = `The result is: ${res}`;
const endTime = performance.now();
const executionTime = endTime - startTime;
console.log('execution time is : ' + executionTime + ' ms');
if (typeof res !== 'object' || res === null) {
const resultElement = document.getElementById('result');
resultElement.innerHTML = `The result is: ${res}`;
}
});
}

0 comments on commit 8711788

Please sign in to comment.