Skip to content

[p5.js 2.0 Bug Report]: Transforms slower than 1.x #8013

@davepagurek

Description

@davepagurek

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?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions