-
-
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.0.7204.169 (Official Build) (arm64)
Operating system
MacOS Sequoia 15.5
Steps to reproduce this
Because of #8013, I ran a couple of performance profiles on the sketch there and noticed something weird - the traces point to get
in bindGlobal
taking up a lot of time,
This is a screenshot of the profile of the sketch shared by @davepagurek in that thread
1.x | 2.x |
---|---|
![]() |
![]() |
Notice how the calls to floor
and random
are significantly slower.
See this test just calling random
:
https://editor.p5js.org/Papershine/sketches/Feun-KSzF
On 2.0 it takes around 140ms while on 1.11 it takes around 10ms.
Maybe the call to bind
every time the function is called might be causing issues?
Lines 105 to 110 in 5ef51ca
get: () => { | |
if(typeof this[property] === 'function'){ | |
return this[property].bind(this); | |
}else{ | |
return this[property]; | |
} |
I'm not sure if this behaviour is intended, but might be worth discussing!