cleanup: ComposeTrace 仅在 debug 构建中启用
- core/build.gradle.kts: 启用 buildConfig 生成 - ComposeTrace: 添加 BuildConfig.DEBUG 条件,release 构建中空操作 避免 R8 full mode 下 Trace 调用的生产环境开销 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dead12fdf4
commit
e934d33cfa
@ -16,6 +16,7 @@ android {
|
|||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
|
buildConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
package plus.rua.project
|
package plus.rua.project
|
||||||
|
|
||||||
import android.os.Trace
|
import android.os.Trace
|
||||||
|
import plus.rua.project.shared.BuildConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Systrace 包装,用于录制 Compose 性能 trace。
|
* Systrace 包装,用于录制 Compose 性能 trace。
|
||||||
* Android 实际调用 android.os.Trace。
|
* 仅在 debug 构建中启用,release 构建中为空操作。
|
||||||
*/
|
*/
|
||||||
fun composeTraceBeginSection(name: String) {
|
fun composeTraceBeginSection(name: String) {
|
||||||
|
if (!BuildConfig.DEBUG) return
|
||||||
try {
|
try {
|
||||||
Trace.beginSection(name)
|
Trace.beginSection(name)
|
||||||
} catch (_: RuntimeException) {
|
} catch (_: RuntimeException) {
|
||||||
@ -15,6 +17,7 @@ fun composeTraceBeginSection(name: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun composeTraceEndSection() {
|
fun composeTraceEndSection() {
|
||||||
|
if (!BuildConfig.DEBUG) return
|
||||||
try {
|
try {
|
||||||
Trace.endSection()
|
Trace.endSection()
|
||||||
} catch (_: RuntimeException) {
|
} catch (_: RuntimeException) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user