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 BusParser(importer) {
23 Parser.call(this, importer);
25 importer.registerEventHandler('memory_bus_usage',
26 BusParser.prototype.traceMarkWriteBusEvent.bind(this));
28 this.model_ = importer.model_;
32 BusParser.prototype = {
33 __proto__: Parser.prototype,
35 traceMarkWriteBusEvent: function(eventName, cpuNumber, pid, ts,
36 eventBase, threadName) {
37 var re = new RegExp('bus=(\\S+) rw_bytes=(\\d+) r_bytes=(\\d+) ' +
38 'w_bytes=(\\d+) cycles=(\\d+) ns=(\\d+)');
39 var event = re.exec(eventBase.details);
42 var rw_bytes = parseInt(event[2]);
43 var r_bytes = parseInt(event[3]);
44 var w_bytes = parseInt(event[4]);
45 var cycles = parseInt(event[5]);
46 var ns = parseInt(event[6]);
49 var r_bw = r_bytes * 1000000000 / ns;
51 var w_bw = w_bytes * 1000000000 / ns;
54 var ctr = this.model_.getOrCreateProcess(0)
55 .getOrCreateCounter(null, 'bus ' + name + ' read');
56 if (ctr.numSeries === 0) {
57 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
58 tvcm.ui.getStringColorId(ctr.name + '.' + 'value')));
60 ctr.series.forEach(function(series) {
61 series.addCounterSample(ts, r_bw);
64 ctr = this.model_.getOrCreateProcess(0)
65 .getOrCreateCounter(null, 'bus ' + name + ' write');
66 if (ctr.numSeries === 0) {
67 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
68 tvcm.ui.getStringColorId(ctr.name + '.' + 'value')));
70 ctr.series.forEach(function(series) {
71 series.addCounterSample(ts, r_bw);
78 Parser.registerSubtype(BusParser);