aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2015-10-20 08:57:26 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-10-20 16:38:02 +0000
commitb51461015186b3781205502cf2dc5c04edde686e (patch)
treea9d8f3662f108816dbb24c2d36ae61f4ae07acba /src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
parentc585530e1acb3ccf9f249e45663704aaba6f6a51 (diff)
Move commandStartTime from BlazeRuntime to CommandEnvironment.
-- MOS_MIGRATED_REVID=105840775
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
index 732c942a6b..9eda313b68 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.runtime;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Range;
import com.google.common.eventbus.EventBus;
import com.google.devtools.build.lib.actions.PackageRootResolver;
import com.google.devtools.build.lib.actions.cache.ActionCache;
@@ -52,6 +53,8 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nullable;
+
/**
* Encapsulates the state needed for a single command. The environment is dropped when the current
* command is done and all corresponding objects are garbage collected.
@@ -68,6 +71,7 @@ public final class CommandEnvironment {
private final LoadingPhaseRunner loadingPhaseRunner;
private final BuildView view;
+ private long commandStartTime;
private String outputFileSystem;
private Path workingDirectory;
@@ -266,8 +270,16 @@ public final class CommandEnvironment {
getWorkingDirectory(), defaultsPackageContents, commandId);
}
+ public void recordLastExecutionTime() {
+ runtime.recordLastExecutionTime(getCommandStartTime());
+ }
+
+ public void recordCommandStartTime(long commandStartTime) {
+ this.commandStartTime = commandStartTime;
+ }
+
public long getCommandStartTime() {
- return runtime.getCommandStartTime();
+ return commandStartTime;
}
void setOutputFileSystem(String outputFileSystem) {
@@ -292,6 +304,8 @@ public final class CommandEnvironment {
void beforeCommand(Command command, OptionsParser optionsParser,
CommonCommandOptions options, long execStartTimeNanos)
throws AbruptExitException {
+ commandStartTime -= options.startupTime;
+
runtime.beforeCommand(command, this, optionsParser, options, execStartTimeNanos);
}
}