Closed chenyunda218 closed 3 weeks ago
The Color
class in packages/math/src/Color.ts
has been updated to include three new static properties and a static method. The properties store sigmoid function results, while the gammaToLinearSpace
method has been restructured to use these properties for calculations instead of previous conditional logic. A new static method, sigmoid
, normalizes input values using the sigmoid function, enhancing the functionality of the gammaToLinearSpace
method without altering existing method signatures or class structure.
File Path | Change Summary |
---|---|
packages/math/src/Color.ts | - Added static properties: gammaToLinearSpaceBranchNumber_0 , gammaToLinearSpaceBranchNumber_0_04045 , gammaToLinearSpaceBranchNumber_1 - Added static method: sigmoid(num: number): number - Restructured gammaToLinearSpace method to utilize new properties and method. |
Color
class in Color.ts
, specifically affecting the gammaToLinearSpace
method, which is also a focus of the main PR's changes.In the realm of colors bright,
New properties take flight,
With sigmoid's gentle grace,
Transforming every space.
Math's magic, clear and true,
A vibrant world anew! 🌈✨
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 69.49%. Comparing base (
e8e8090
) to head (c2e7613
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The PR has lint errors, you can fix them with lint --fix
The PR has lint errors, you can fix them with
lint --fix
Thanks, I've fixed it.
After detailed testing, it was found that this PR actually caused performance degradation. The case is as follows: https://jsbench.me/vqm2u50u6r/1 Can you confirm whether it can be improved?
We are happy for you to submit PRs and hope you can continue to contribute!
After my testing. it depending on runtime. In nodejs the new one faster. In chrome same. Other runtime is slower. So i think it is not a good refactor. Apologize for my negligence.
After my testing. it depending on runtime. In nodejs the new one faster. In chrome same. Other runtime is slower. So i think it is not a good refactor. Apologize for my negligence.
The impact of the environment on performance is indeed complex! Welcome to join us, we can keep in touch with issues and PRs!
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
refactor function for enhance performance.
What is the current behavior? (You can also link to an open issue here)
Color.gammaToLinearSpace is so many branch cause break cpu Branch predictor.
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
There is about 3e-11 in the precision of floating point numbers between two version.
Summary by CodeRabbit
sigmoid
method for normalizing values between 0 and 1.gammaToLinearSpace
method for more efficient calculations, eliminating previous conditional checks.