Add option to run safetynet_compare.py without a profiler.

This is useful for comparing images without slowing down performance
with a profiler.

Change-Id: Ia0c41bf8ef32d82bbc24f47f44586e22d991aa51
Reviewed-on: https://pdfium-review.googlesource.com/32352
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/testing/tools/safetynet_compare.py b/testing/tools/safetynet_compare.py
index 96691096..ef47eab 100755
--- a/testing/tools/safetynet_compare.py
+++ b/testing/tools/safetynet_compare.py
@@ -644,8 +644,8 @@
                            'script is killed or crashes the changes can remain '
                            'stashed and you may be on another branch.')
   parser.add_argument('--profiler', default='callgrind',
-                      help='which profiler to use. Supports callgrind and '
-                           'perfstat for now. Default is callgrind.')
+                      help='which profiler to use. Supports callgrind, '
+                           'perfstat, and none. Default is callgrind.')
   parser.add_argument('--interesting-section', action='store_true',
                       help='whether to measure just the interesting section or '
                            'the whole test harness. Limiting to only the '
diff --git a/testing/tools/safetynet_measure.py b/testing/tools/safetynet_measure.py
index ac362b2..55046a2 100755
--- a/testing/tools/safetynet_measure.py
+++ b/testing/tools/safetynet_measure.py
@@ -19,6 +19,7 @@
 
 CALLGRIND_PROFILER = 'callgrind'
 PERFSTAT_PROFILER = 'perfstat'
+NONE_PROFILER = 'none'
 
 PDFIUM_TEST = 'pdfium_test'
 
@@ -55,6 +56,8 @@
       time = self._RunCallgrind()
     elif self.args.profiler == PERFSTAT_PROFILER:
       time = self._RunPerfStat()
+    elif self.args.profiler == NONE_PROFILER:
+      time = self._RunWithoutProfiler()
     else:
       PrintErr('profiler=%s not supported, aborting' % self.args.profiler)
       return 1
@@ -102,6 +105,19 @@
     # '        12345      instructions'
     return self._ExtractIrCount(r'\b(\d+)\b.*\binstructions\b', output)
 
+  def _RunWithoutProfiler(self):
+    """Runs test harness and measures performance without a profiler.
+
+    Returns:
+      int with the result of the measurement, in instructions or time. In this
+      case, always return 1 since no profiler is being used.
+    """
+    cmd_to_run = self._BuildTestHarnessCommand()
+    output = subprocess.check_output(cmd_to_run, stderr=subprocess.STDOUT)
+
+    # Return 1 for every run.
+    return 1
+
   def _BuildTestHarnessCommand(self):
     """Builds command to run the test harness."""
     cmd = [self.pdfium_test_path, '--send-events']
@@ -135,8 +151,8 @@
                       help='relative path to the build directory with '
                            '%s' % PDFIUM_TEST)
   parser.add_argument('--profiler', default=CALLGRIND_PROFILER,
-                      help='which profiler to use. Supports callgrind and '
-                           'perfstat for now.')
+                      help='which profiler to use. Supports callgrind, '
+                           'perfstat, and none.')
   parser.add_argument('--interesting-section', action='store_true',
                       help='whether to measure just the interesting section or '
                            'the whole test harness. The interesting section is '