feat: Optimize performance with dirty flag - #7
Closed
Initsnow wants to merge 2 commits into
Closed
Conversation
✅ Deploy Preview for notedigger ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Owner
|
感谢你的优化。毫无疑问你的pr能减轻cpu负担,cpu负担也确实主要来自每帧的重绘,但出于以下原因我觉得合并需谨慎: 首先,当前修改中的置位并非最佳位置,且存在重复。你的修改集中于用户操作后,导致很多地方都需要置位。然而多处存在重复置位的情况,比如161行的 其次,多处增加dirty导致维护困难。曾经我也考虑过并非帧帧需要重绘,但每加一个功能就要溯源判断是否已经会刷新 非常累,若忘了dirty设置还会有bug,所以我没有优化这一点。类似的地方是MidiAction.updateView,我选择了用户操作后才刷新,当时代码就写得非常累。如果将类似的操作拓展到整个应用的刷新,我不敢想象以后有多难维护。 再者,我并不认为cpu占用多有什么很大的影响。如果页面显示,说明用户要操作,高点就高点吧。如果页面被遮住不可见,则重绘会自己暂停,并不再占用。 最后是我认为如果要改有更好的做法。以下设想择其一即可:
|
将刷新分为四个部分 - resize - 用户操作(鼠标键盘等) - 分析完成(Spectrogram setter; CQT结束) - 播放时(AudioPlayer.update)
Owner
|
按照设想1更改了一下,看起来能用,但不知道有没有bug |
Author
|
None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
减少空闲时的CPU usage