mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
use Matter.Runner in test worker
This commit is contained in:
parent
a30707fd87
commit
2581595e6e
1 changed files with 7 additions and 2 deletions
|
@ -12,7 +12,12 @@ const runExample = options => {
|
||||||
|
|
||||||
const Examples = requireUncached('../examples/index');
|
const Examples = requireUncached('../examples/index');
|
||||||
const example = Examples[options.name]();
|
const example = Examples[options.name]();
|
||||||
|
|
||||||
const engine = example.engine;
|
const engine = example.engine;
|
||||||
|
const runner = example.runner;
|
||||||
|
|
||||||
|
runner.delta = 1000 / 60;
|
||||||
|
runner.isFixed = true;
|
||||||
|
|
||||||
let totalMemory = 0;
|
let totalMemory = 0;
|
||||||
let totalDuration = 0;
|
let totalDuration = 0;
|
||||||
|
@ -25,7 +30,7 @@ const runExample = options => {
|
||||||
const startTime = process.hrtime();
|
const startTime = process.hrtime();
|
||||||
totalMemory += process.memoryUsage().heapUsed;
|
totalMemory += process.memoryUsage().heapUsed;
|
||||||
|
|
||||||
Matter.Engine.update(engine, 1000 / 60);
|
Matter.Runner.tick(runner, engine, i * runner.delta);
|
||||||
|
|
||||||
const duration = process.hrtime(startTime);
|
const duration = process.hrtime(startTime);
|
||||||
totalDuration += duration[0] * 1e9 + duration[1];
|
totalDuration += duration[0] * 1e9 + duration[1];
|
||||||
|
|
Loading…
Reference in a new issue