[1143] 窗口构造三项延后优化,tm_widget ctor 185ms → 110ms#4027
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- checkNetworkAvailable 改 singleShot(0),省构造期创建 QNetworkAccessManager 的 ~37ms - QWK::LoginDialog 惰性创建(ensureLoginDialog 首次显示时才 new + setupLoginDialog),移出构造期 ~90-113ms - 已登录时 refreshMembershipInfoInBackground 改 singleShot(0), ctor 尾部 43ms → 0ms 关键结论:ensure_window 内大块成本是 Qt 子系统一次性暖场, 只在构造内部删项会让成本迁移到下一个重控件;把工作挪到事件 循环起跑后(singleShot(0))才真正出关键路径。实测见 devel/1143.md 3.5。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
checkNetworkAvailable()改QTimer::singleShot(0),移出构造期 QNetworkAccessManager 首次创建的 ~37msQWK::LoginDialog惰性创建:新增ensureLoginDialog(),首次显示时才new+setupLoginDialog,移出构造期 ~90-113msrefreshMembershipInfoInBackground()改singleShot(0),ctor 尾部 43ms → 0ms关键结论:ensure_window 内大块成本是 Qt 子系统一次性暖场(字体/样式/网络栈),只在构造内部删项会让成本迁移到下一个重控件(status bar 段 0→53ms);把工作挪到事件循环起跑后才真正出关键路径——延后后网络栈首次初始化在事件循环里仅 1ms。
实测(同机三次运行):tm_widget ctor 合计 185ms → 110ms,ensure_window ~204ms → ~166ms。
Test plan
xmake b stem构建通过🤖 Generated with Claude Code