Utility for counting frame time and frames per interval.
npm install frame-delta --save
var FrameDelta = FrameDelta;var sleep = ;// Create a new `FrameDelta` instance and tell it that we are aiming for// 30 FPS. The `1000` (given to the constructor in the line below) is the// interval (in milliseconds) that we want the `FrameDelta` to update its// FPI.var frames = 1000;framestargetFPI = 30;// Enter a render/update loop.while windowIsOpen;;// We can get the frames per interval (FPI) and frame time from the// instance. These values will be `0` the first time we print them, as// it takes at least one render/update loop iteration before these values// can be determined.console;console;// Based on the current frame time (duration between last two frame// updates), the `FrameDelta` instance will suggest the optimal amount// of time we can suspend the thread so we don't hammer the CPU, whilst// still allowing us to get our target FPI.await ;// Tell the instance that the frame is over.thisframes;
frame-delta is built using
gulp. You can invoke the build process by using
gulp directly, or via an npm script which calls
both the npm script and the
gulp command do exactly the same thing.)
npm run build// Orgulp build
LICENSE file for license information.