Marcin RobaczyĆski
03/06/2024, 3:14 PMtasks.configureEach { task ->
if (task.name.startsWith("assembleDebug")) {
println "Track start time"
task.doLast {
println "Track end time"
}
}
}
Running benchmarks is of course an option but I wanted to see an overall trend on a day-to-day develoment among devs.Marcin RobaczyĆski
03/06/2024, 3:18 PM--profile
option and parse the results - but wouldn't that slow down the overall build?Alex Semin
03/07/2024, 7:27 AM--scan
.
If you still prefer a home-cooked solution, the javadoc to the method you linked points you to the FlowProviders.getBuildWorkResult()
in the âsee alsoâ section. This is a Configuration Cache compatible replacement for the deprecated method.
Here are more docs on this: https://docs.gradle.org/current/userguide/dataflow_actions.htmlMarcin RobaczyĆski
03/07/2024, 10:10 AMfailure
field. Now I realise that I can just observe it and hook up start time / end time within. Thanks!Marcin RobaczyĆski
03/08/2024, 4:09 PMstartTime
value here would be cached as soon as the plugin is applied đ€
@Suppress("UnstableApiUsage")
abstract class BuildTimeTracker : Plugin<Project> {
@get:Inject
abstract val flowScope: FlowScope
@get:Inject
abstract val flowProviders: FlowProviders
override fun apply(target: Project) {
flowScope.always(BuildTimeTrackAction::class.java) {
val startTime = System.currentTimeMillis()
it.parameters.buildTime.set(
flowProviders.buildWorkResult.map {
System.currentTimeMillis() - startTime
},
)
}
}
}
@Suppress("UnstableApiUsage")
abstract class BuildTimeTrackAction : FlowAction<Params> {
interface Params : FlowParameters {
@get:Input
val buildTime: Property<Long>
}
override fun execute(parameters: Params) {
println("Build time: ${parameters.buildTime.get()}ms")
}
}
Alex Semin
03/11/2024, 5:09 AMFlowProviders api will only let me know when build completesThatâs correct. Currently, itâs the only use-case for the API
TheCorrect, the plugin application (and the whole configuration phase) can be skipped on a Configuration Cache hit, for instance. I am unsure if there is a public API for the start time of the build. However, there are many existing open-source plugins that try to measure the same thing. Maybe they can give inspiration đvalue here would be cached as soon as the plugin is applied đ€startTime