Last active
June 21, 2022 08:10
-
-
Save jonnycaley/528d8ce4a68dd9661cc8adefc2413588 to your computer and use it in GitHub Desktop.
BuildDurationService - build and configuration time
This file contains 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
abstract class BuildDurationService : BuildService<BuildServiceParameters.None>, BuildOperationListener, AutoCloseable { | |
var buildDuration: Long? = null | |
var configurationDuration: Long? = null | |
var configurationPhaseFailed = true | |
override fun started(p0: BuildOperationDescriptor, p1: OperationStartEvent) {} | |
override fun progress(p0: OperationIdentifier, p1: OperationProgressEvent) {} | |
override fun finished(buildOperationDescriptor: BuildOperationDescriptor, operationFinishEvent: OperationFinishEvent) { | |
if (buildOperationDescriptor.details is RunRootBuildWorkBuildOperationType.Details) { | |
/** | |
* Runs when build phase finishes, therefore we can assume configuration phase passed | |
*/ | |
configurationPhaseFailed = false | |
val details = buildOperationDescriptor.details as RunRootBuildWorkBuildOperationType.Details? | |
details?.buildStartTime?.let { buildStartTime -> | |
buildDuration = System.currentTimeMillis() - buildStartTime | |
val firstTaskStartTime = operationFinishEvent.startTime | |
this.configurationDuration = firstTaskStartTime - buildStartTime | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment