3 种方案,不可忽视的构建分析
本文作者
作者:yechaoa
链接:
https://juejin.cn/post/7282150745164005432
本文由作者授权发布。
构建性能对于生产力至关重要。
Build Analyzer Profile Build Scan
2.1、Overview
为确保数据准确有效,建议先执行clean。
2.2、Tasks
2.3、Warnings
2.4、Downloads
切到Downloads选项可以查看下载信息,有些下载很慢的话可以添加一下镜像啊,或者调整一下仓库地址顺序啊,还有就是动态版本每次都要下载是不是可以考虑优化一下啊等等,非常有帮助。
./gradlew assembleDebug --profile
➜ GradleX git:(master) ✗ ./gradlew assembleDebug --profile
BUILD SUCCESSFUL in 3s
34 actionable tasks: 34 executed
See the profiling report at: file:///Users/yechao/AndroidStudioProjects/GradleX/build/reports/profile/profile-2023-09-24-15-50-21.html
3.1、Summary
3.2、Configuaration
3.3、Dependency Resolution
3.4、Artifact Transforms
3.5、Task Execution
这是因为这里统计的是Task执行的总时长,实际编译过程中Task是并行在跑的,所以会出现大于总时长的情况。
./gradlew build --scan
Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service.
Do you accept these terms? [yes, no]
Gradle Terms of Service accepted.
Publishing build scan...
https://gradle.com/s/bv5a4lsy47vni
链接贴这里,大家也可以查看。
https://scans.gradle.com/s/v76tzpjhivzte
4.1、Summary
4.2、Performance
4.3、Task execution
4.4、Timeline
4.5、switches
比如我这里Cache都没开,并行编译也没开,离线也没开,如果这些都开了,构建性能又会有大大的提升。
Build Analyzer:开发工具提供,不割裂,但是分析能力相对基础,不过一般也够用了,推荐; Profile:本地分析报告,分析能力相对基础; Build Scan:在线分析报告,分析能力较强,可以进行深入的分析,推荐;
以上是Build Scan免费版和付费版的对比,大家感兴趣的话可以自行去官网了解。
https://gradle.com/gradle-enterprise-solutions/build-scan-root-cause-analysis-data/
GitHub
Profile your build
https://developer.android.google.cn/build/profile-your-build
Inspecting Gradle Builds
https://developer.android.google.cn/build/profile-your-build
Build Analyzer
https://developer.android.google.cn/studio/build/build-analyzer?hl=zh-cn
scans.gradle.com
https://scans.gradle.com/
最后推荐一下我做的网站,玩Android: wanandroid.com ,包含详尽的知识体系、好用的工具,还有本公众号文章合集,欢迎体验和收藏!
推荐阅读:
扫一扫 关注我的公众号
如果你想要跟大家分享你的文章,欢迎投稿~
┏(^0^)┛明天见!