-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Performance improvements for colors #8355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-2.0
Are you sure you want to change the base?
Conversation
|
I may need to double check but I think |
|
I think that'd mean we can take out the |
|
I see there are some parsing needed to get the additional information like mode when passed a string. I think this should be fine for now and we can continue to optimize as needed. For the performance, I'm not seeing much difference between the custom build in the linked sketch and 1.x on my machine, I find framerate usually not a very good indicator, but we can benchmark in more detail as well later. |
|
That's good if it's hitting the same frame rate as 1.x for you at least! Is something like this safe enough to merge as is or do you think this warrants more benchmarking and testing? |
Addresses #8316
Changes:
defaultStringValue: if present, just return that instead of going through colorjs. That gives us an opportunity to add some custom faster logic in key places.CanvasRenderingContext2D, so if you create a color that way, we can use the string directly as thedefaultStringValue_colorobject to be lazy: it only gets created if we need it, e.g. if we're converting between color modes. This saves a little time in less complex cases.Mapwhere we can quickly see itssizeand remove items if need be.Live: https://editor.p5js.org/davepagurek/sketches/UG6fwp2hc
In this test sketch, I get 40fps where in 2.1.2 I get 12fps. Note that in 1.11.1, it still achieves >50fps though. But it's an improvement.
PR Checklist
npm run lintpasses