1 // Copyright (c) 2012 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.
8 * @fileoverview Parses trace_marker events that were inserted in the trace by
11 tvcm.require('tracing.importer.linux_perf.parser');
12 tvcm.require('tracing.trace_model.counter_series');
14 tvcm.exportTo('tracing.importer.linux_perf', function() {
16 var Parser = tracing.importer.linux_perf.Parser;
19 * Parses linux trace mark events that were inserted in the trace by userland.
22 function ClockParser(importer) {
23 Parser.call(this, importer);
25 importer.registerEventHandler('clock_set_rate',
26 ClockParser.prototype.traceMarkWriteClockEvent.bind(this));
28 this.model_ = importer.model_;
32 ClockParser.prototype = {
33 __proto__: Parser.prototype,
35 traceMarkWriteClockEvent: function(eventName, cpuNumber, pid, ts,
36 eventBase, threadName) {
37 var event = /(\S+) state=(\d+) cpu_id=(\d+)/.exec(eventBase.details);
41 var rate = parseInt(event[2]);
43 var ctr = this.model_.getOrCreateProcess(0)
44 .getOrCreateCounter(null, name);
45 // Initialize the counter's series fields if needed.
46 if (ctr.numSeries === 0) {
47 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
48 tvcm.ui.getStringColorId(ctr.name + '.' + 'value')));
50 ctr.series.forEach(function(series) {
51 series.addCounterSample(ts, rate);
58 Parser.registerSubtype(ClockParser);
61 ClockParser: ClockParser