Skip to content

Instantly share code, notes, and snippets.

@jonnycaley
Last active June 21, 2022 08:10
Show Gist options
  • Save jonnycaley/8ef3a52ac8d68c5956bc460099dd36f2 to your computer and use it in GitHub Desktop.
Save jonnycaley/8ef3a52ac8d68c5956bc460099dd36f2 to your computer and use it in GitHub Desktop.
BuildDurationService - Capturing build time
abstract class BuildDurationService : BuildService<BuildServiceParameters.None>, BuildOperationListener, AutoCloseable {
var buildDuration: Long? = null
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) {
val details = buildOperationDescriptor.details as RunRootBuildWorkBuildOperationType.Details?
details?.buildStartTime?.let { buildStartTime ->
buildDuration = System.currentTimeMillis() - buildStartTime
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment