about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-12-07T15·09+0100
committerEelco Dolstra <edolstra@gmail.com>2016-12-07T15·09+0100
commitb07060688a298abe765bca4258de4c675b24a364 (patch)
tree7f44131fa022886fb78576443eba0a3b79d14b60 /src
parentdadfddfa7cb5d523969bffd906b74099d6a88387 (diff)
Keep track of the exact build start/stop times
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc4
-rw-r--r--src/libstore/store-api.hh4
-rw-r--r--src/nix-store/nix-store.cc2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 2bc167fee5ca..8442f1f613b7 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1347,6 +1347,7 @@ void DerivationGoal::tryToBuild()
             case rpAccept:
                 /* Yes, it has started doing so.  Wait until we get
                    EOF from the hook. */
+                result.startTime = time(0); // inexact
                 state = &DerivationGoal::buildDone;
                 return;
             case rpPostpone:
@@ -1424,6 +1425,7 @@ void DerivationGoal::buildDone()
     debug(format("builder process for ‘%1%’ finished") % drvPath);
 
     result.timesBuilt++;
+    result.stopTime = time(0);
 
     /* So the child is gone now. */
     worker.childTerminated(this);
@@ -2108,6 +2110,8 @@ void DerivationGoal::startBuilder()
     /* Create a pipe to get the output of the builder. */
     builderOut.create();
 
+    result.startTime = time(0);
+
     /* Fork a child to build the package. */
 #if __linux__
     if (useChroot) {
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index ee2b6b2862b6..789526cc2b70 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -218,7 +218,9 @@ struct BuildResult
        non-determinism.) */
     bool isNonDeterministic = false;
 
-    //time_t startTime = 0, stopTime = 0;
+    /* The start/stop times of the build (or one of the rounds, if it
+       was repeated). */
+    time_t startTime = 0, stopTime = 0;
 
     bool success() {
         return status == Built || status == Substituted || status == AlreadyValid;
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 6ab62f53a2ae..f81cff4accd3 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -961,7 +961,7 @@ static void opServe(Strings opFlags, Strings opArgs)
                 out << status.status << status.errorMsg;
 
                 if (GET_PROTOCOL_MINOR(clientVersion) >= 3)
-                    out << status.timesBuilt << status.isNonDeterministic;
+                    out << status.timesBuilt << status.isNonDeterministic << status.startTime << status.stopTime;
 
                 break;
             }