-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.3
Web browser and version
Chrome 138
Operating system
MacOS
Steps to reproduce this
@wagedu was testing performance of this sketch https://editor.p5js.org/davepagurek/sketches/VNdy3pSOQ and noticed that it's ~3x slower on 2.x than 1.x.
I took a performance profile of both and noticed that much of that slowdown happens when applying transformations for each object in the sketch. Particularly, matrix operations appear to take a lot longer.
Some potential things to fix: the isPerfectSquare
function gets called multiple times and involves an array copy each time. Can the array copy be removed, and the multiple calls cached? (Moreover, do we actually need this check for now? @GregStanton @holomorfo I wonder if there's a way in our matrix design that we can do this check in createMatrix
and then all internal matrix creations, where we know the size will be valid, we can skip the extra check, only doing it when processing user-provided data?)