Remove dependency on bc

This makes installation easier for systems that don't come with bc installed (e.g., Travis CI and Ubuntu Vivid Vervet).

--
MOS_MIGRATED_REVID=91297054
diff --git a/.travis/build.sh b/.travis/build.sh
index 6b201cf..f51677d 100755
--- a/.travis/build.sh
+++ b/.travis/build.sh
@@ -25,7 +25,7 @@
     brew install protobuf libarchive
 else
     sudo apt-get update -qq
-    sudo apt-get install -y protobuf-compiler libarchive-dev bc netcat-traditional
+    sudo apt-get install -y protobuf-compiler libarchive-dev netcat-traditional
     sudo update-alternatives --set nc /bin/nc.traditional
     export JAVA_HOME=/usr/lib/jvm/java-8-oracle
     export JAVA_OPTS="-Xmx3000m"
diff --git a/src/test/shell/unittest.bash b/src/test/shell/unittest.bash
index b33b790..3e6f424 100644
--- a/src/test/shell/unittest.bash
+++ b/src/test/shell/unittest.bash
@@ -461,14 +461,21 @@
 if [ "$(uname -s | tr 'A-Z' 'a-z')" = "darwin" ]; then
     function timestamp() {
       # OS X does not have %N so python is the best we can do
-      python -c 'import time; print time.time()'
+      python -c 'import time; print int(round(time.time() * 1000))'
     }
 else
     function timestamp() {
-      date +%s.%N
+      echo $(($(date +%s%N)/1000000))
     }
 fi
 
+function get_run_time() {
+  local ts_start=$1
+  local ts_end=$2
+  run_time_ms=$((${ts_end}-${ts_start}))
+  echo $(($run_time_ms/1000)).${run_time_ms: -3}
+}
+
 # Usage: run_tests <suite-comment>
 # Must be called from the end of the user's test suite.
 # Calls exit with zero on success, non-zero otherwise.
@@ -536,7 +543,7 @@
         # Calculate run time for the testcase.
         local ts_start=$(cat $TEST_TMPDIR/__ts_start)
         local ts_end=$(cat $TEST_TMPDIR/__ts_end)
-        run_time=$(echo "${ts_end}-${ts_start}" | bc)
+        run_time=$(get_run_time $ts_start $ts_end)
 
         # Eventually restore exit handlers.
         if [ -n "$SAVED_ATEXIT" ]; then
diff --git a/src/test/shell/unittest_test.sh b/src/test/shell/unittest_test.sh
index a204944..2f8299d 100755
--- a/src/test/shell/unittest_test.sh
+++ b/src/test/shell/unittest_test.sh
@@ -28,4 +28,12 @@
   echo "Everything is okay in test_2"
 }
 
+function test_timestamp() {
+  local ts=$(timestamp)
+  [[ $ts =~ ^[0-9]{13}$ ]] || fail "timestamp wan't valid: $ts"
+
+  local time_diff=$(get_run_time 100000 223456)
+  assert_equals $time_diff 123.456
+}
+
 run_suite "unittests Tests"