diff --git a/package.json b/package.json index 3862610f..b742fd42 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "test:wtest": "mocha --delay -t 10000 -r ts-node/register/transpile-only test/wtest.ts", "test:printer": "mocha --parallel -r ts-node/register/transpile-only test/printer.test.ts", "test:parser": "mocha -r ts-node/register/transpile-only test/parser.test.ts", - "test:benchmarks": "mocha -t 100000 -r ts-node/register/transpile-only test/benchmarks.ts", + "test:benchmarks": "mocha -t 999999 -r ts-node/register/transpile-only test/benchmarks.ts", "lint:fix": "eslint . --fix", "validate:wollokVersion": "ts-node scripts/validateWollokVersion.ts", "prepublishOnly": "npm run validate:wollokVersion && npm run build && npm test", diff --git a/test/benchmarks.ts b/test/benchmarks.ts index e58efa88..d2fa4f7f 100644 --- a/test/benchmarks.ts +++ b/test/benchmarks.ts @@ -29,7 +29,7 @@ describe('Benchmarks', () => { const time = totalTime / iterations - const deltaError = Math.max(0.1, expectedTime * 0.1) // 0.1 or 10 % + const deltaError = expectedTime * 0.15 // 15 % restore() // console.info(`${message} - ${fqn} - ${time} ms (${iterations} iterations)`) @@ -38,13 +38,13 @@ describe('Benchmarks', () => { }) } - benchmark('empty', 0.55) - benchmark('visuals_1', 0.4) - benchmark('visuals_100', 0.3) - benchmark('ticks_1', 0.8) - benchmark('ticks_100', 44) - benchmark('onCollide_1', 0.8) - benchmark('onCollide_100', 44) + benchmark('empty', 3.5) + benchmark('visuals_1', 3.1) + benchmark('visuals_100', 2.6) + benchmark('ticks_1', 7.7) + benchmark('ticks_100', 430) + benchmark('onCollide_1', 7.5) + benchmark('onCollide_100', 440) }) }) @@ -58,7 +58,8 @@ async function measure(programFQN: string, message: string): Promise { interpreter.send(message, game, interpreter.reify(0)) // Fill caches const startTime = performance.now() - interpreter.send(message, game, interpreter.reify(1)) + for (let ms = 1; ms < 10; ms++) + interpreter.send(message, game, interpreter.reify(ms)) const endTime = performance.now() const elapsedTime = endTime - startTime