diff --git a/src/core/Engine.js b/src/core/Engine.js index 3e439a7..9bb3250 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -54,7 +54,9 @@ var Body = require('../body/Body'); plugin: {}, timing: { timestamp: 0, - timeScale: 1 + timeScale: 1, + lastDelta: 0, + lastElapsed: 0 }, broadphase: { controller: Grid @@ -111,6 +113,8 @@ var Body = require('../body/Body'); * @param {number} [correction=1] */ Engine.update = function(engine, delta, correction) { + var startTime = Common.now(); + delta = delta || 1000 / 60; correction = correction || 1; @@ -122,6 +126,7 @@ var Body = require('../body/Body'); // increment timestamp timing.timestamp += delta * timing.timeScale; + timing.lastDelta = delta * timing.timeScale; // create an event object var event = { @@ -229,6 +234,9 @@ var Body = require('../body/Body'); Events.trigger(engine, 'afterUpdate', event); + // log the time elapsed computing this update + engine.timing.lastElapsed = Common.now() - startTime; + return engine; };