1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 from telemetry.core.platform import profiler
10 class TraceProfiler(profiler.Profiler):
12 def __init__(self, browser_backend, platform_backend, output_path, state):
13 super(TraceProfiler, self).__init__(
14 browser_backend, platform_backend, output_path, state)
15 assert self._browser_backend.supports_tracing
16 self._browser_backend.StartTracing(None, timeout=10)
23 def is_supported(cls, browser_type):
26 def CollectProfile(self):
27 print 'Processing trace...'
29 trace_result = self._browser_backend.StopTracing()
31 trace_file = '%s.json' % self._output_path
33 with codecs.open(trace_file, 'w', encoding='utf-8') as f:
34 trace_result.Serialize(f)
36 print 'Trace saved as %s' % trace_file
37 print 'To view, open in chrome://tracing'