def _StartProfiling(self, page): output_file = os.path.join(self._finder_options.output_dir, page.file_safe_name) if self._finder_options.pageset_repeat != 1: output_file = util.GetSequentialFileName(output_file) self.browser.profiling_controller.Start(self._finder_options.profiler, output_file)
def _StartProfiling(self, page): output_file = os.path.join(self._finder_options.output_dir, page.file_safe_name) is_repeating = (self._finder_options.page_repeat != 1 or self._finder_options.pageset_repeat != 1) if is_repeating: output_file = util.GetSequentialFileName(output_file) self.platform.profiling_controller.Start(self._finder_options.profiler, output_file)
def StartProfiling(self, page, finder_options): if not self.profiler_dir: self.profiler_dir = tempfile.mkdtemp() output_file = os.path.join(self.profiler_dir, page.file_safe_name) is_repeating = (finder_options.page_repeat != 1 or finder_options.pageset_repeat != 1) if is_repeating: output_file = util.GetSequentialFileName(output_file) self.browser.StartProfiling(finder_options.profiler, output_file)
def testGetSequentialFileNameWithOtherSequentialFiles(self): # Create test_000.json, test_001.json, test_002.json in test directory. for i in xrange(3): with open(os.path.join(self.test_directory, 'test_%03d.json' % i), 'w') as _: pass next_json_test_file_path = util.GetSequentialFileName( os.path.join(self.test_directory, 'test')) self.assertEquals(os.path.join(self.test_directory, 'test_003'), next_json_test_file_path)
def ValidateAndMeasurePage(self, page, tab, results): """ Collect all possible metrics and added them to results. """ trace_result = tab.browser.platform.tracing_controller.Stop() trace_dir = self.options.trace_dir if trace_dir: trace_file_path = util.GetSequentialFileName( os.path.join(trace_dir, 'trace')) + '.json' try: with open(trace_file_path, 'w') as f: trace_result.Serialize(f) results.AddValue(string_value_module.StringValue( page, 'trace_path', 'string', trace_file_path)) except IOError, e: logging.error('Cannot open %s. %s' % (trace_file_path, e))
def testGetSequentialFileNameNoOtherSequentialFile(self): next_json_test_file_path = util.GetSequentialFileName( os.path.join(self.test_directory, 'test')) self.assertEquals(os.path.join(self.test_directory, 'test_000'), next_json_test_file_path)