git-cl: Report presubmit execution time.

Bug: 970113
Change-Id: Iff31287d1ab8f683f7745fd0abc62b138ffcf219
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1642649
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 0df89c4..cb1f087 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1591,11 +1591,18 @@
   def RunHook(self, committing, may_prompt, verbose, change, parallel):
     """Calls sys.exit() if the hook fails; returns a HookResults otherwise."""
     try:
-      return presubmit_support.DoPresubmitChecks(change, committing,
+      start = time_time()
+      result = presubmit_support.DoPresubmitChecks(change, committing,
           verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin,
           default_presubmit=None, may_prompt=may_prompt,
           gerrit_obj=self._codereview_impl.GetGerritObjForPresubmit(),
           parallel=parallel)
+      metrics.collector.add_repeated('sub_commands', {
+        'command': 'presubmit',
+        'execution_time': time_time() - start,
+        'exit_code': 0 if result.should_continue() else 1,
+      })
+      return result
     except presubmit_support.PresubmitFailure as e:
       DieWithError('%s\nMaybe your depot_tools is out of date?' % e)