Unify allocator tests even more, also test arena

This commit is contained in:
dcodeIO
2018-03-04 17:25:32 +01:00
parent 4257273d42
commit 00c4f6fa52
36 changed files with 3463 additions and 2977 deletions

View File

@ -1,28 +0,0 @@
const fs = require("fs");
function test(file) {
console.log("Testing '" + file + "' ...\n");
const exports = new WebAssembly.Instance(WebAssembly.Module(fs.readFileSync(__dirname + "/" + file)), {
env: {
abort: function(msg, file, line, column) {
throw Error("Assertion failed: " + (msg ? "'" + getString(msg) + "' " : "") + "at " + getString(file) + ":" + line + ":" + column);
},
log: function(ptr) { console.log(getString(ptr)); },
logi: function(i) { console.log(i); }
}
}).exports;
function getString(ptr) {
var len = new Uint32Array(exports.memory.buffer, ptr)[0];
var str = new Uint16Array(exports.memory.buffer, ptr + 4).subarray(0, len);
return String.fromCharCode.apply(String, str);
}
require("../runner")(exports, 50, 20000); // picked so I/O isn't the bottleneck
console.log("mem final: " + exports.memory.buffer.byteLength);
console.log();
}
test("tlsf.untouched.wasm");
test("tlsf.optimized.wasm");

View File

@ -2,9 +2,7 @@
"private": true,
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "asc assembly/index.ts -t tlsf.untouched.wat -b tlsf.untouched.wasm --validate --sourceMap --measure",
"build:optimized": "asc assembly/index.ts -t tlsf.optimized.wat -b tlsf.optimized.wasm --validate --sourceMap --measure --noDebug --noAssert --optimize",
"test": "node ./index",
"test:forever": "node ../forever tlsf"
"build:untouched": "asc assembly/index.ts -t untouched.wat -b untouched.wasm --validate --sourceMap --measure",
"build:optimized": "asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noDebug --noAssert --optimize"
}
}