phetsims / gene-expression-essentials

An educational simulation about how genes work to create proteins.
GNU General Public License v3.0
4 stars 6 forks source link

limiting dt instead of skipping it might yield better performance #67

Closed jbphet closed 7 years ago

jbphet commented 7 years ago

In the step functions for both ManualGeneExpressionModel.js and MessengerRnaProductionModel.js I'm seeing code that looks like this:

      if ( dt > 0.2 ) {
        return;
      }

This means that when long dt values come in, the model won't advance at all. It might improve the visual performance of the simulation to instead limit the dt value to a some max value that the sim is known to be able to handle, perhaps something like this:

  // (in the constants area)
  var NOMINAL_TIME_STEP = 1/60; // nominal time step for 60fps
  var MAX_TIME_STEP = 3 * NOMINAL_TIME_STEP; // max time step that the model is known to handle well
  .
  .
  .
  // (in the step function)
  // limit time step the max value that the model can handle
  dt = Math.min( dt, MAX_TIME_STEP );
aadish commented 7 years ago

fixed closing