Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

A plugin that generates the compose metrics report and provides a way to check thresholds that you have set in the build gradle file

License

Notifications You must be signed in to change notification settings

oas004/VerifyComposeMetricsPlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c4c4b1d · Jan 9, 2023

History

10 Commits
Dec 11, 2022
Dec 11, 2022
Jan 4, 2023
Jan 4, 2023
Dec 11, 2022
Dec 11, 2022
Jan 9, 2023
Dec 11, 2022
Dec 11, 2022
Dec 11, 2022
Dec 11, 2022
Dec 11, 2022

Repository files navigation

VerifyComposeMetricsPlugin

This is a small plugin that generates the compose metrics and checks that you have not crossed the threshold that you have set.

The Compose Metrics report is generated from the Compiler report

Implementation

Add plugin to plugins block

plugins {
    id("com.metrics.verify.compose.metrics") version "1.0-SNAPSHOT"
}

Use the VerifyComposeMetricsConfig to configure the plugin.

VerifyComposeMetricsConfig {
    inferredUnstableClassThreshold = 0
    errorAsWarning = false
    generateComposeMetricsReport = true
    skipVerification = true
    printMetricsInfo = true
}

Verifying inferred unstable classes

Unstable classes can be inferred by the Compose compiler, if a class has an argument that is considered unstable. This can lead to the composable using the class not being skippable. This can in turn lead to perfomance issues down the line. An example of an unstable class can be something like this

data class UnstableClass(
    var greeting: String = "Hey this makes me an unstable type!"
)

This is because the class parameter is a var.

If you want to read more about @Stable classes and performance i would recommend this blogpost.

If you want to limit the amount of inferred unstable classes, you can configure the VerifyComposeMetricsConfig with a inferredUnstableClassThreshold. This will make the ./gradlew verifyComposeMetrics task fail if the module has crossed the threshold. If you just want it to print a warning, you can use the errorAsWarning flag and set it to true.

Generate the report

If you just want to generate the compose metrics report, I can suggest setting the generateComposeMetricsReport flag to true. This will generate a report in your build folder. The task for checking the thresholds also requires you to have a metrics report generated in your build file.

Skip Verification

Using the skipVerification flag will skip all the threshold checks.

Print the report

Setting the printMetricsInfo to true will print a version of the ComposeMetrics report to the log.

Contributing

Plese contribute if you want! Feel free to open an issue if there is anything you want to discuss or anything is off.

License

MIT License

Copyright (c) 2022 Odin Asbjørnsen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

A plugin that generates the compose metrics report and provides a way to check thresholds that you have set in the build gradle file

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages