Properly report C++ build time.
diff --git a/tools/jenkins/build_and_run_docker.sh b/tools/jenkins/build_and_run_docker.sh
index 448b00c..18b910a 100755
--- a/tools/jenkins/build_and_run_docker.sh
+++ b/tools/jenkins/build_and_run_docker.sh
@@ -46,16 +46,18 @@
# Use image name based on Dockerfile location checksum
DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
-# Make sure docker image has been built. Should be instantaneous if so.
-docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
-
-# Choose random name for docker container
-CONTAINER_NAME="build_and_run_docker_$(uuidgen)"
-
# Ensure existence of ccache directory
CCACHE_DIR=/tmp/protobuf-ccache
mkdir -p $CCACHE_DIR
+# Make sure docker image has been built. Should be instantaneous if so.
+docker build \
+ -v $CCACHE_DIR:$CCACHE_DIR \
+ -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
+
+# Choose random name for docker container
+CONTAINER_NAME="build_and_run_docker_$(uuidgen)"
+
# Run command inside docker
docker run \
"$@" \
diff --git a/tools/jenkins/make_test_output.py b/tools/jenkins/make_test_output.py
index 0ba5db3..986d197 100644
--- a/tools/jenkins/make_test_output.py
+++ b/tools/jenkins/make_test_output.py
@@ -58,8 +58,8 @@
# up in the job log.
tests["cpp"]["name"] = "cpp"
- # TODO
- tests["cpp"]["time"] = "0"
+ with open(basedir + '/logs/1/cpp/build_time', 'r') as f:
+ tests["cpp"]["time"] = f.read().strip()
tests["cpp"]["failure"] = False
ret = tests.values()
diff --git a/tools/run_tests/jenkins.sh b/tools/run_tests/jenkins.sh
index 32050d2..0bd9ffe 100755
--- a/tools/run_tests/jenkins.sh
+++ b/tools/run_tests/jenkins.sh
@@ -34,7 +34,12 @@
# $DIR/logs/1/java_jdk7/stderr
CPP_STDOUT=$LOG_OUTPUT_DIR/1/cpp/stdout
CPP_STDERR=$LOG_OUTPUT_DIR/1/cpp/stderr
-$TEST_SCRIPT cpp > >(tee $CPP_STDOUT) 2> >(tee $CPP_STDERR >&2)
+
+# It's important that we get /usr/bin/time (which supports -f and -o) and not
+# the bash builtin "time" which doesn't.
+TIME_CMD="/usr/bin/time -f %e -o $LOG_OUTPUT_DIR/1/cpp/build_time"
+
+$TIME_CMD $TEST_SCRIPT cpp > >(tee $CPP_STDOUT) 2> >(tee $CPP_STDERR >&2)
# Other tests are run in parallel. The overall run fails if any one of them
# fails.