[Autotest] Time the staging of control files.

To debug some apache slowness this cl times the staging/parsing of
control files. This operation is the main suspect for the slowness
of the create_suite_job rpc.

TEST=Executed the rpc.
BUG=None
DEPLOY=apache

Change-Id: I3c3892054a33a52dd31d467567b09862395dc91b
Reviewed-on: https://chromium-review.googlesource.com/231079
Reviewed-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 618841e..68c0bd1 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -60,9 +60,14 @@
     @return the contents of the desired control file.
     """
     getter = control_file_getter.DevServerGetter.create(build, ds)
+    timer = stats.Timer('control_files.parse.%s.%s' %
+                        (ds.get_server_name(ds.url()).replace('.', '_'),
+                            suite_name.rsplit('.')[-1]))
     # Get the control file for the suite.
     try:
-        control_file_in = getter.get_control_file_contents_by_name(suite_name)
+        with timer:
+            control_file_in = getter.get_control_file_contents_by_name(
+                    suite_name)
     except error.CrosDynamicSuiteException as e:
         raise type(e)("%s while testing %s." % (e, build))
     if not control_file_in:
@@ -95,8 +100,11 @@
     # components to be downloaded in the background.
     ds = dev_server.ImageServer.resolve(build)
     timings[constants.DOWNLOAD_STARTED_TIME] = formatted_now()
+    timer = stats.Timer('control_files.stage.%s' % (
+                    ds.get_server_name(ds.url()).replace('.', '_')))
     try:
-        ds.stage_artifacts(build, ['test_suites'])
+        with timer:
+            ds.stage_artifacts(build, ['test_suites'])
     except dev_server.DevServerException as e:
         raise error.StageControlFileFailure(
                 "Failed to stage %s: %s" % (build, e))