3 Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/importer/linux_perf/parser.html">
9 <link rel="import" href="/tracing/trace_model/counter_series.html">
15 * @fileoverview Parses trace_marker events that were inserted in the trace by
18 tv.exportTo('tracing.importer.linux_perf', function() {
20 var Parser = tracing.importer.linux_perf.Parser;
23 * Parses linux trace mark events that were inserted in the trace by userland.
26 function ClockParser(importer) {
27 Parser.call(this, importer);
29 importer.registerEventHandler('clock_set_rate',
30 ClockParser.prototype.traceMarkWriteClockEvent.bind(this));
32 this.model_ = importer.model_;
36 ClockParser.prototype = {
37 __proto__: Parser.prototype,
39 traceMarkWriteClockEvent: function(eventName, cpuNumber, pid, ts,
40 eventBase, threadName) {
41 var event = /(\S+) state=(\d+) cpu_id=(\d+)/.exec(eventBase.details);
45 var rate = parseInt(event[2]);
47 var ctr = this.model_.getOrCreateProcess(0)
48 .getOrCreateCounter(null, name);
49 // Initialize the counter's series fields if needed.
50 if (ctr.numSeries === 0) {
51 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
52 tv.ui.getStringColorId(ctr.name + '.' + 'value')));
54 ctr.series.forEach(function(series) {
55 series.addCounterSample(ts, rate);
62 Parser.registerSubtype(ClockParser);
65 ClockParser: ClockParser