コード例 #1
0
ファイル: profiler.py プロジェクト: sencha/chromium-spacewalk
def _PullTraces(controllers, output, compress, write_json):
    ui.PrintMessage('Downloading...', eol='')
    trace_files = [controller.PullTrace() for controller in controllers]
    trace_files = [trace for trace in trace_files if trace]
    if not trace_files:
        ui.PrintMessage('No results')
        return []
    result = trace_packager.PackageTraces(trace_files,
                                          output=output,
                                          compress=compress,
                                          write_json=write_json)
    ui.PrintMessage('done')
    ui.PrintMessage('Trace written to file://%s' % os.path.abspath(result))
    return result
コード例 #2
0
  def testJsonTraceMerging(self):
    t1 = {'traceEvents': [{'ts': 123, 'ph': 'b'}]}
    t2 = {'traceEvents': [], 'stackFrames': ['blah']}

    # Both trace files will be merged to a third file and will get deleted in
    # the process, so there's no need for NamedTemporaryFile to do the
    # deletion.
    with tempfile.NamedTemporaryFile(delete=False) as f1, \
        tempfile.NamedTemporaryFile(delete=False) as f2:
      f1.write(json.dumps(t1))
      f2.write(json.dumps(t2))
      f1.flush()
      f2.flush()

      with tempfile.NamedTemporaryFile() as output:
        trace_packager.PackageTraces([f1.name, f2.name],
                                     output.name,
                                     compress=False,
                                     write_json=True)
        with open(output.name) as output:
          output = json.load(output)
          self.assertEquals(output['traceEvents'], t1['traceEvents'])
          self.assertEquals(output['stackFrames'], t2['stackFrames'])
コード例 #3
0
ファイル: newBrowser.py プロジェクト: lambda-fairy/erlnmyr
      f.flush();
      sys.stderr.write('flushed');

      if options.perf:
        sys.stderr.write('Downloading perf data and symbols from device...')
        perf_data = browser.profiling_controller.Stop();
        sys.stderr.write('Converting perf data to JSON\n')
        json_perf_data = [convertPerfProfileToJSON(i) for i in perf_data]
        json_perf_data = [i for i in json_perf_data if i is not None]

        json_perf_data.append(f.name)

        merged_profile = tempfile.NamedTemporaryFile();
        output = os.path.join(tempfile.tempdir, merged_profile.name)
        sys.stderr.write('Merging Traces\n')
        combined = trace_packager.PackageTraces(json_perf_data, output=output, compress=False, write_json=False)
        sys.stderr.write("Trace written to file://%s" % os.path.abspath(combined))

      sys.stdout.write(f.name + '\n');
      sys.stdout.flush();
      command = sys.stdin.readline()[:-1];
      assert command == 'done';
      f.close();
    elif command.startswith('exec:'):
      length = int(command[5:]);
      js = sys.stdin.read(length);
      result = tab.EvaluateJavaScript(js);
      f = tempfile.NamedTemporaryFile();
      f.write(dumps(result));
      f.flush();
      sys.stdout.write(f.name + '\n');