3 Copyright (c) 2013 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() {
19 var Parser = tracing.importer.linux_perf.Parser;
22 * Parses linux trace mark events that were inserted in the trace by userland.
25 function BusParser(importer) {
26 Parser.call(this, importer);
28 importer.registerEventHandler('memory_bus_usage',
29 BusParser.prototype.traceMarkWriteBusEvent.bind(this));
31 this.model_ = importer.model_;
35 BusParser.prototype = {
36 __proto__: Parser.prototype,
38 traceMarkWriteBusEvent: function(eventName, cpuNumber, pid, ts,
39 eventBase, threadName) {
40 var re = new RegExp('bus=(\\S+) rw_bytes=(\\d+) r_bytes=(\\d+) ' +
41 'w_bytes=(\\d+) cycles=(\\d+) ns=(\\d+)');
42 var event = re.exec(eventBase.details);
45 var rw_bytes = parseInt(event[2]);
46 var r_bytes = parseInt(event[3]);
47 var w_bytes = parseInt(event[4]);
48 var cycles = parseInt(event[5]);
49 var ns = parseInt(event[6]);
52 var r_bw = r_bytes * 1000000000 / ns;
54 var w_bw = w_bytes * 1000000000 / ns;
57 var ctr = this.model_.getOrCreateProcess(0)
58 .getOrCreateCounter(null, 'bus ' + name + ' read');
59 if (ctr.numSeries === 0) {
60 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
61 tv.ui.getStringColorId(ctr.name + '.' + 'value')));
63 ctr.series.forEach(function(series) {
64 series.addCounterSample(ts, r_bw);
67 ctr = this.model_.getOrCreateProcess(0)
68 .getOrCreateCounter(null, 'bus ' + name + ' write');
69 if (ctr.numSeries === 0) {
70 ctr.addSeries(new tracing.trace_model.CounterSeries('value',
71 tv.ui.getStringColorId(ctr.name + '.' + 'value')));
73 ctr.series.forEach(function(series) {
74 series.addCounterSample(ts, r_bw);
81 Parser.registerSubtype(BusParser);