Search in sources :

Example 31 with Timer

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));
}
Also used : UnitOfWork(org.gradle.internal.execution.UnitOfWork) ExecutionOutcome(org.gradle.internal.execution.ExecutionOutcome) Timer(org.gradle.internal.time.Timer) InputChangesInternal(org.gradle.internal.execution.history.changes.InputChangesInternal) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Duration(java.time.Duration) PreviousExecutionState(org.gradle.internal.execution.history.PreviousExecutionState)

Example 32 with Timer

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));
}
Also used : DefaultAfterExecutionState(org.gradle.internal.execution.history.impl.DefaultAfterExecutionState) AfterExecutionState(org.gradle.internal.execution.history.AfterExecutionState) Timer(org.gradle.internal.time.Timer) OutputSnapshotter(org.gradle.internal.execution.OutputSnapshotter) DefaultAfterExecutionState(org.gradle.internal.execution.history.impl.DefaultAfterExecutionState) Duration(java.time.Duration) OriginMetadata(org.gradle.caching.internal.origin.OriginMetadata) FileSystemSnapshot(org.gradle.internal.snapshot.FileSystemSnapshot)

Example 33 with Timer

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());
}
Also used : Timer(org.gradle.internal.time.Timer)

Aggregations

Timer (org.gradle.internal.time.Timer)33 File (java.io.File)6 IOException (java.io.IOException)5 Duration (java.time.Duration)3 HashMap (java.util.HashMap)3 ClassSetAnalysisData (org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData)3 LinkedHashMap (java.util.LinkedHashMap)2 GradleException (org.gradle.api.GradleException)2 DefaultResolvedDependency (org.gradle.api.internal.artifacts.DefaultResolvedDependency)2 DependencyGraphNodeResult (org.gradle.api.internal.artifacts.DependencyGraphNodeResult)2 ResolvedConfigurationIdentifier (org.gradle.api.internal.artifacts.ResolvedConfigurationIdentifier)2 RecompilationSpec (org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec)2 WorkResult (org.gradle.api.tasks.WorkResult)2 OriginMetadata (org.gradle.caching.internal.origin.OriginMetadata)2 ExecutionOutcome (org.gradle.internal.execution.ExecutionOutcome)2 AfterExecutionState (org.gradle.internal.execution.history.AfterExecutionState)2 FileSystemSnapshot (org.gradle.internal.snapshot.FileSystemSnapshot)2 JavaExecHandleBuilder (org.gradle.process.internal.JavaExecHandleBuilder)2 WorkerProcess (org.gradle.process.internal.worker.WorkerProcess)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1