phetsims / projectile-data-lab

"Projectile Data Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 0 forks source link

Performance improvements for autogenerate data #192

Closed samreid closed 5 months ago

samreid commented 6 months ago

From #146,

    // TODO: Can we performance optimize by setting directly in the landedProjectiles? See https://github.com/phetsims/projectile-data-lab/issues/146
    this.projectileLandedEmitter.emit( projectile );
samreid commented 6 months ago

@matthew-blackman and I agreed to close this issue because performance seems reasonable. If we need a performance boost in the future, we will use profiling+optimizing. Closing.

Nancy-Salpepi commented 5 months ago

Going to reopen this issue. For https://github.com/phetsims/qa/issues/1060 with a Lenovo 100e Chromebook, it took between 9 and 12 seconds to autogenerate a sample when n=40 on the sampling screen. On other screens, it takes between 1-2 seconds.

samreid commented 5 months ago

There was an O(n^2) loop condition that was taking >50% of the CPU in that case. On my macbook air M1 it took roughly 1130ms to run one 40 autogenerate sample.

In the commit, I optimized the while loop condition so it is no longer O(n^2) and it now takes roughly 484ms on my device. This is taking 43% of the time. If that translates to the chromebook, then 12 seconds may go to 5.1s.

Nancy-Salpepi commented 5 months ago

Wow! Performance is much better on the Chromebook...only a short delay (< 3 seconds). Can we close this now @samreid?

samreid commented 5 months ago

Yes, that seems great! Thanks for testing. Closing.