Skip to content

Commit b070606

Browse files
committed
Keep track of the exact build start/stop times
1 parent dadfddf commit b070606

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/libstore/build.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ void DerivationGoal::tryToBuild()
13471347
case rpAccept:
13481348
/* Yes, it has started doing so. Wait until we get
13491349
EOF from the hook. */
1350+
result.startTime = time(0); // inexact
13501351
state = &DerivationGoal::buildDone;
13511352
return;
13521353
case rpPostpone:
@@ -1424,6 +1425,7 @@ void DerivationGoal::buildDone()
14241425
debug(format("builder process for ‘%1%’ finished") % drvPath);
14251426

14261427
result.timesBuilt++;
1428+
result.stopTime = time(0);
14271429

14281430
/* So the child is gone now. */
14291431
worker.childTerminated(this);
@@ -2108,6 +2110,8 @@ void DerivationGoal::startBuilder()
21082110
/* Create a pipe to get the output of the builder. */
21092111
builderOut.create();
21102112

2113+
result.startTime = time(0);
2114+
21112115
/* Fork a child to build the package. */
21122116
#if __linux__
21132117
if (useChroot) {

src/libstore/store-api.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ struct BuildResult
218218
non-determinism.) */
219219
bool isNonDeterministic = false;
220220

221-
//time_t startTime = 0, stopTime = 0;
221+
/* The start/stop times of the build (or one of the rounds, if it
222+
was repeated). */
223+
time_t startTime = 0, stopTime = 0;
222224

223225
bool success() {
224226
return status == Built || status == Substituted || status == AlreadyValid;

src/nix-store/nix-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static void opServe(Strings opFlags, Strings opArgs)
961961
out << status.status << status.errorMsg;
962962

963963
if (GET_PROTOCOL_MINOR(clientVersion) >= 3)
964-
out << status.timesBuilt << status.isNonDeterministic;
964+
out << status.timesBuilt << status.isNonDeterministic << status.startTime << status.stopTime;
965965

966966
break;
967967
}

0 commit comments

Comments
 (0)