Skip to main content

Performance

Although the physics functionality requires substantial mathematical calculations each frame, in most cases it will have very little impact on performance. Unlike a complex video game, cognitive assessments will not have many physics bodies in a scene.

To monitor the impact of the physics engine on performance, pass the option logEngineStats: true when creating the Physics instance. This will log to the console the average duration, over the last 60 frames, the physics engine has taken to process a single frame.

When the assessment is running at 60 frames per second, there are 1000 / 60 or about 16 milliseconds maximum available for computation. Usually the physics engine takes only a fraction of a millisecond to update each frame.

After you press "Go", the example drops 50 balls. Click on a ball to apply an upward force to it. 50 is probably more physics bodies than you would ever need in a real assessment, but try increasing NUMBER_OF_BALLS until it starts to affect performance -- or crashes your web browser! (Be sure to click "Run" again after changing NUMBER_OF_BALLS).

warning

Usually, a developer's desktop computer can handle many more physics bodies than a mobile device. Always test your assessment on the lowest-powered mobile device you expect your users to have to make sure it performs well.

Loading...