Send execution time to dashboard.

Change-Id: I60812715cea6050a6e73a44d4789d3d4d84216e6
diff --git a/benchmarks/src/main/scripts/commitDate b/benchmarks/src/main/scripts/commitDate
index 08d52f7..5b71145 100755
--- a/benchmarks/src/main/scripts/commitDate
+++ b/benchmarks/src/main/scripts/commitDate
@@ -11,4 +11,4 @@
 COMMIT_ID=${2}
 
 cd ${SOURCE_LOCATION}
-git show -s --format=%ci ${COMMIT_ID}
\ No newline at end of file
+git show -s --format=%ct ${COMMIT_ID}
diff --git a/common/src/main/java/com/google/gwt/benchmark/common/shared/json/BenchmarkRunJson.java b/common/src/main/java/com/google/gwt/benchmark/common/shared/json/BenchmarkRunJson.java
index e02cea2..c01679a 100644
--- a/common/src/main/java/com/google/gwt/benchmark/common/shared/json/BenchmarkRunJson.java
+++ b/common/src/main/java/com/google/gwt/benchmark/common/shared/json/BenchmarkRunJson.java
@@ -23,15 +23,29 @@
  */
 public interface BenchmarkRunJson {
 
+  String getCommitId();
+
+  /**
+   * Get the commit time of the patch in milliseconds since 1970.
+   * <p>
+   * Note: This is not the author time of the commit, but the time it has been merged into the
+   * repository
+   */
+  double getCommitTimeMsEpoch();
+
+  Map<String, List<BenchmarkResultJson>> getResultByBenchmarkName();
+
   void setResultByBenchmarkName(Map<String, List<BenchmarkResultJson>> results);
 
   void setCommitId(String commitId);
 
   void setCommitTime(String commitTime);
 
-  String getCommitTime();
-
-  String getCommitId();
-
-  Map<String, List<BenchmarkResultJson>> getResultByBenchmarkName();
+  /**
+   * Set the commit time of the patch in milliseconds since 1970.
+   * <p>
+   * Note: This is not the author time of the commit, but the time it has been merged into the
+   * repository
+   */
+  void setCommitTimeMsEpoch(double commitMsEpoch);
 }
diff --git a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManager.java b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManager.java
index e84553c..870d86e 100644
--- a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManager.java
+++ b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManager.java
@@ -102,7 +102,7 @@
         }
       }
       if (workCount.decrementAndGet() == 0) {
-        maybeReportResults(benchmarkRun.getCommitId(), benchmarkRun.getCommitDate());
+        maybeReportResults(benchmarkRun.getCommitId(), benchmarkRun.getCommitMsEpoch());
       }
     }
 
@@ -162,7 +162,7 @@
 
   private BenchmarkWorker.Factory benchmarkWorkerFactory;
 
-  private String currentCommitDate;
+  private long currentCommitDateMsEpoch;
 
   private boolean currentlyRunning = false;
 
@@ -280,13 +280,13 @@
   }
 
   private BenchmarkRun createBenchmarkRunForModule(String moduleName, String commitId,
-      String commitDate) {
-    BenchmarkRun br = new BenchmarkRun(moduleName, commitId, commitDate);
+      long currentCommitDateMsEpoch) {
+    BenchmarkRun br = new BenchmarkRun(moduleName, commitId, currentCommitDateMsEpoch);
     br.addRunner(RunnerConfigs.FIREFOX_LINUX);
     return br;
   }
 
-  private void maybeReportResults(String commitId, String commitDate) {
+  private void maybeReportResults(String commitId, long commitMsEpoch) {
     Map<String, BenchmarkRun> results;
     synchronized (benchmarkRunsByNameLock) {
       results = deepClone(benchmarkRunsByName);
@@ -324,7 +324,7 @@
         commands.add(Command.SUCCESSFUL_RUN);
       }
     };
-    new Thread(reporterFactory.create(results, commitId, commitDate, p)).start();
+    new Thread(reporterFactory.create(results, commitId, commitMsEpoch, p)).start();
   }
 
   private Command getNextCommand() {
@@ -345,7 +345,7 @@
       setLastCommit(cliInteractor.getLastCommitId());
       currentCommitId = getLastCommitId();
       logger.info(String.format("Last commit was %s", currentCommitId));
-      currentCommitDate = cliInteractor.getDateForCommit(currentCommitId);
+      currentCommitDateMsEpoch = cliInteractor.getDateForCommitInMsEpoch(currentCommitId);
       logger.info("Checking out last commit");
       cliInteractor.checkout(getLastCommitId());
 
@@ -390,12 +390,12 @@
               logger.info(String.format("found a new commit %s", currentCommitId));
 
               logger.info("Getting its commit date");
-              currentCommitDate = cliInteractor.getDateForCommit(currentCommitId);
+              currentCommitDateMsEpoch = cliInteractor.getDateForCommitInMsEpoch(currentCommitId);
 
               logger.info("Building SDK");
               cliInteractor.buildSDK();
               logger.info("Starting benchmark runners");
-              startBenchmarkingAllForCommit(currentCommitId, currentCommitDate);
+              startBenchmarkingAllForCommit(currentCommitId, currentCommitDateMsEpoch);
               state = State.RUNNING_BENCHMARKS;
             }
 
@@ -424,7 +424,7 @@
             continue;
           }
           state = State.RUNNING_BENCHMARKS;
-          startBenchmarkingAllForCommit(currentCommitId, currentCommitDate);
+          startBenchmarkingAllForCommit(currentCommitId, currentCommitDateMsEpoch);
           break;
 
         case SUCCESSFUL_RUN:
@@ -448,7 +448,7 @@
     }
   }
 
-  private void startBenchmarkingAllForCommit(String commitId, String commitDate) {
+  private void startBenchmarkingAllForCommit(String commitId, long currentCommitDateMsEpoch) {
 
     pool = poolProvider.get();
 
@@ -461,7 +461,8 @@
         continue;
       }
 
-      BenchmarkRun br = createBenchmarkRunForModule(benchmarkModuleName, commitId, commitDate);
+      BenchmarkRun br = createBenchmarkRunForModule(benchmarkModuleName, commitId,
+          currentCommitDateMsEpoch);
       addBenchmarkRun(br);
 
       ProgressHandler progressHandler = new ThreadSafeProgressHandler(br);
diff --git a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporter.java b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporter.java
index a04cc56..6989d6f 100644
--- a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporter.java
+++ b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporter.java
@@ -56,7 +56,7 @@
 
   public interface Factory {
     BenchmarkReporter create(Map<String, BenchmarkRun> results,
-        @Assisted("commitId") String commitId, @Assisted("commitDate") String commitDate,
+        @Assisted("commitId") String commitId, @Assisted("commitDate") long commitMsEpoch,
         ReportProgressHandler reportProgressHandler);
   }
 
@@ -71,17 +71,17 @@
 
   private final ReportProgressHandler reportProgressHandler;
 
-  private final String commitDate;
+  private final long commitMsEpoch;
 
   @Inject
   public BenchmarkReporter(HttpURLConnectionFactory httpURLConnectionFactory,
       @Assisted Map<String, BenchmarkRun> results, @Assisted("commitId") String commitId,
-      @Assisted("commitDate") String commitDate,
+      @Assisted("commitDate") long commitMsEpoch,
       @Assisted ReportProgressHandler reportProgressHandler) {
     this.httpURLConnectionFactory = httpURLConnectionFactory;
     this.results = results;
     this.commitId = commitId;
-    this.commitDate = commitDate;
+    this.commitMsEpoch = commitMsEpoch;
     this.reportProgressHandler = reportProgressHandler;
   }
 
@@ -116,7 +116,7 @@
 
     BenchmarkRunJson runJSON = factory.run().as();
     runJSON.setCommitId(commitId);
-    runJSON.setCommitTime(commitDate);
+    runJSON.setCommitTimeMsEpoch((double)commitMsEpoch);
     Map<String, List<BenchmarkResultJson>> results = new LinkedHashMap<>();
 
     for (Entry<String, BenchmarkRun> br : this.results.entrySet()) {
diff --git a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkRun.java b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkRun.java
index 6172e3e..5b5ee4f 100644
--- a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkRun.java
+++ b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkRun.java
@@ -69,7 +69,7 @@
   }
 
   public static BenchmarkRun from(BenchmarkRun other) {
-    BenchmarkRun clone = new BenchmarkRun(other.moduleName, other.commitId, other.commitDate);
+    BenchmarkRun clone = new BenchmarkRun(other.moduleName, other.commitId, other.commitMsEpoch);
     clone.runners = other.getRunConfigs();
     clone.results = deepClone(other.results);
     clone.state = other.state;
@@ -97,12 +97,12 @@
 
   private String errorMessage;
 
-  private final String commitDate;
+  private final long commitMsEpoch;
 
-  public BenchmarkRun(String moduleName, String commitId, String commitDate) {
+  public BenchmarkRun(String moduleName, String commitId, long commitMsEpoch) {
     this.moduleName = moduleName;
     this.commitId = commitId;
-    this.commitDate = commitDate;
+    this.commitMsEpoch = commitMsEpoch;
     state = State.NOT_RUN;
   }
 
@@ -123,8 +123,8 @@
     result.setRunsPerSecond(runsPerSecond);
   }
 
-  public String getCommitDate() {
-    return commitDate;
+  public long getCommitMsEpoch() {
+    return commitMsEpoch;
   }
 
   public String getCommitId() {
diff --git a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractor.java b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractor.java
index ee51a8d..07df0ff 100644
--- a/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractor.java
+++ b/compileserver/src/main/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractor.java
@@ -95,10 +95,13 @@
         gitCommitScript.getAbsolutePath() + " " + gwtSourceLocation.getAbsolutePath());
   }
 
-  public String getDateForCommit(String currentCommitId) throws BenchmarkManagerException {
+  public long getDateForCommitInMsEpoch(String currentCommitId) throws BenchmarkManagerException {
     File commitDateScript = new File(scriptDirectory, "commitDate");
-    return runCommand(commitDateScript.getAbsolutePath() + " " + gwtSourceLocation.getAbsolutePath()
-        + " " + currentCommitId);
+    String dateForCommitString = runCommand(commitDateScript.getAbsolutePath() + " "
+        + gwtSourceLocation.getAbsolutePath() + " " + currentCommitId);
+    // cut off new line
+    dateForCommitString = dateForCommitString.substring(0, dateForCommitString.length() - 1);
+    return Long.valueOf(dateForCommitString) * 1000;
   }
 
   public String getLastCommitId() throws BenchmarkManagerException {
diff --git a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManagerTest.java b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManagerTest.java
index 0649b71..06a2747 100644
--- a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManagerTest.java
+++ b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkManagerTest.java
@@ -136,7 +136,7 @@
         ArgumentCaptor.forClass(ReportProgressHandler.class);
 
     Mockito.when(reporterFactory.create(resultCaptor.capture(), Mockito.anyString(),
-        Mockito.anyString(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
+        Mockito.anyLong(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
 
     Assert.assertFalse(manager.isRunning());
 
@@ -267,7 +267,7 @@
         timerProvider,
         errorReporter);
 
-    Mockito.when(commitReader.getDateForCommit(Mockito.anyString())).thenThrow(
+    Mockito.when(commitReader.getDateForCommitInMsEpoch(Mockito.anyString())).thenThrow(
         new BenchmarkManagerException(""));
 
     Assert.assertFalse(manager.isRunning());
@@ -352,7 +352,7 @@
         ArgumentCaptor.forClass(ReportProgressHandler.class);
 
     Mockito.when(reporterFactory.create(resultCaptor.capture(), Mockito.anyString(),
-        Mockito.anyString(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
+        Mockito.anyLong(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
 
     Assert.assertFalse(manager.isRunning());
 
@@ -451,7 +451,7 @@
         ArgumentCaptor.forClass(ReportProgressHandler.class);
 
     Mockito.when(reporterFactory.create(resultCaptor.capture(), Mockito.anyString(),
-        Mockito.anyString(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
+        Mockito.anyLong(), reportProgressHandlerCaptor.capture())).thenReturn(benchmarkReporter);
 
     Assert.assertFalse(manager.isRunning());
 
diff --git a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporterTest.java b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporterTest.java
index 8e12795..73cd09d 100644
--- a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporterTest.java
+++ b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/BenchmarkReporterTest.java
@@ -46,13 +46,13 @@
   private HttpURLConnection urlConnection;
   private OutputStream outputStream;
   private String commitId;
-  private String commitDate;
+  private long commitDate;
   private ReportProgressHandler reportProgressHandler;
 
   @Before
   public void setup() {
     commitId = "commitId1";
-    commitDate = "my commit date";
+    commitDate = 77;
 
     results = new HashMap<>();
     BenchmarkRun benchmarkRun = new BenchmarkRun("module1", commitId, commitDate);
@@ -103,7 +103,7 @@
     BenchmarkRunJson benchmarkRunJSON = bean.as();
 
     Assert.assertEquals(commitId, benchmarkRunJSON.getCommitId());
-    Assert.assertEquals(commitDate, benchmarkRunJSON.getCommitTime());
+    Assert.assertEquals(commitDate, benchmarkRunJSON.getCommitTimeMsEpoch(), 0.0001);
 
     Map<String, List<BenchmarkResultJson>> resultsJSON =
         benchmarkRunJSON.getResultByBenchmarkName();
diff --git a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractorTest.java b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractorTest.java
index 26ed5ca..983c99e 100644
--- a/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractorTest.java
+++ b/compileserver/src/test/java/com/google/gwt/benchmark/compileserver/server/manager/CliInteractorTest.java
@@ -132,14 +132,8 @@
 
   @Test
   public void testGetDateForCommit() throws BenchmarkManagerException {
-    String date = scriptInteractor.getDateForCommit("asdf1");
-    // Cut off new line char
-    date = date.substring(0, date.length() - 1);
-
-    String[] split = date.split(";");
-    Assert.assertEquals(2, split.length);
-    Assert.assertEquals(gwtSourceLocation.getAbsolutePath(), split[0]);
-    Assert.assertEquals("asdf1", split[1]);
+    long date = scriptInteractor.getDateForCommitInMsEpoch("asdf1");
+    Assert.assertEquals(1234987000L, date);
   }
 
   @Test
@@ -147,7 +141,7 @@
     scriptInteractor = new CliInteractor(scriptDirectoryFail, persistenceDir, gwtSourceLocation,
         benchmarkSourceLocation);
     try {
-      scriptInteractor.getDateForCommit("commitId1");
+      scriptInteractor.getDateForCommitInMsEpoch("commitId1");
       Assert.fail("Expected exception did not occur");
     } catch (BenchmarkManagerException e) {
       Assert.assertEquals("Command returned with 1 commitDate: This is my errormessage!\n",
diff --git a/compileserver/src/test/resources/scripts-working/commitDate b/compileserver/src/test/resources/scripts-working/commitDate
index 87042bf..e394575 100755
--- a/compileserver/src/test/resources/scripts-working/commitDate
+++ b/compileserver/src/test/resources/scripts-working/commitDate
@@ -6,7 +6,4 @@
   exit 1
 fi
 
-
-SOURCE_LOCATION=${1}
-COMMIT_ID=${2}
-echo "${SOURCE_LOCATION};${COMMIT_ID}"
\ No newline at end of file
+echo "1234987"
\ No newline at end of file