use of org.gradle.internal.time.Timer in project gradle by gradle.
the class ExecuteStep method executeInternal.
private static Result executeInternal(UnitOfWork work, InputChangesContext context) {
UnitOfWork.ExecutionRequest executionRequest = new UnitOfWork.ExecutionRequest() {
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<InputChangesInternal> getInputChanges() {
return context.getInputChanges();
}
@Override
public Optional<ImmutableSortedMap<String, FileSystemSnapshot>> getPreviouslyProducedOutputs() {
return context.getPreviousExecutionState().map(PreviousExecutionState::getOutputFilesProducedByWork);
}
};
UnitOfWork.WorkOutput workOutput;
Timer timer = Time.startTimer();
try {
workOutput = work.execute(executionRequest);
} catch (Throwable t) {
return ResultImpl.failed(t, Duration.ofMillis(timer.getElapsedMillis()));
}
Duration duration = Duration.ofMillis(timer.getElapsedMillis());
ExecutionOutcome outcome = determineOutcome(context, workOutput);
return ResultImpl.success(duration, new ExecutionResultImpl(outcome, workOutput));
}
use of org.gradle.internal.time.Timer in project gradle by gradle.
the class CaptureStateAfterExecutionStep method captureStateAfterExecution.
private Optional<AfterExecutionState> captureStateAfterExecution(UnitOfWork work, BeforeExecutionContext context, BeforeExecutionState beforeExecutionState, Duration duration) {
return operation(operationContext -> {
try {
Timer timer = Time.startTimer();
ImmutableSortedMap<String, FileSystemSnapshot> outputsProducedByWork = captureOutputs(work, context, beforeExecutionState);
long snapshotOutputDuration = timer.getElapsedMillis();
// The origin execution time is recorded as “work duration” + “output snapshotting duration”,
// As this is _roughly_ the amount of time that is avoided by reusing the outputs,
// which is currently the _only_ thing this value is used for.
Duration originExecutionTime = duration.plus(Duration.ofMillis(snapshotOutputDuration));
OriginMetadata originMetadata = new OriginMetadata(buildInvocationScopeId.asString(), originExecutionTime);
AfterExecutionState afterExecutionState = new DefaultAfterExecutionState(beforeExecutionState, outputsProducedByWork, originMetadata, false);
operationContext.setResult(Operation.Result.INSTANCE);
return Optional.of(afterExecutionState);
} catch (OutputSnapshotter.OutputFileSnapshottingException e) {
work.handleUnreadableOutputs(e);
operationContext.setResult(Operation.Result.INSTANCE);
return Optional.empty();
}
}, BuildOperationDescriptor.displayName("Snapshot outputs after executing " + work.getDisplayName()).details(Operation.Details.INSTANCE));
}
use of org.gradle.internal.time.Timer in project gradle by gradle.
the class DefaultTaskExecutionGraph method executeWithServices.
private void executeWithServices(ProjectExecutionServiceRegistry projectExecutionServices, Collection<? super Throwable> failures) {
Timer clock = Time.startTimer();
planExecutor.process(executionPlan, failures, new BuildOperationAwareExecutionAction(buildOperationExecutor.getCurrentOperation(), new InvokeNodeExecutorsAction(nodeExecutors, projectExecutionServices)));
LOGGER.debug("Timing: Executing the DAG took {}", clock.getElapsed());
}
Aggregations