blob: 2998ee95961e66d4db96446111b625824a891287 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/tracing/extras/importer/linux_perf/parser.html">
<link rel="import" href="/tracing/model/counter_series.html">
<script>
'use strict';
/**
* @fileoverview Parses trace_marker events that were inserted in the trace by
* userland.
*/
tr.exportTo('tr.e.importer.linux_perf', function() {
var Parser = tr.e.importer.linux_perf.Parser;
/**
* Parses linux trace mark events that were inserted in the trace by userland.
* @constructor
*/
function BusParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('memory_bus_usage',
BusParser.prototype.traceMarkWriteBusEvent.bind(this));
this.model_ = importer.model_;
this.ppids_ = {};
}
BusParser.prototype = {
__proto__: Parser.prototype,
traceMarkWriteBusEvent: function(eventName, cpuNumber, pid, ts,
eventBase, threadName) {
var re = new RegExp('bus=(\\S+) rw_bytes=(\\d+) r_bytes=(\\d+) ' +
'w_bytes=(\\d+) cycles=(\\d+) ns=(\\d+)');
var event = re.exec(eventBase.details);
var name = event[1];
var rw_bytes = parseInt(event[2]);
var r_bytes = parseInt(event[3]);
var w_bytes = parseInt(event[4]);
var cycles = parseInt(event[5]);
var ns = parseInt(event[6]);
// BW in MB/s
var r_bw = r_bytes * 1000000000 / ns;
r_bw /= 1024 * 1024;
var w_bw = w_bytes * 1000000000 / ns;
w_bw /= 1024 * 1024;
var ctr = this.model_.kernel
.getOrCreateCounter(null, 'bus ' + name + ' read');
if (ctr.numSeries === 0) {
ctr.addSeries(new tr.model.CounterSeries('value',
tr.ui.b.getColorIdForGeneralPurposeString(
ctr.name + '.' + 'value')));
}
ctr.series.forEach(function(series) {
series.addCounterSample(ts, r_bw);
});
ctr = this.model_.kernel
.getOrCreateCounter(null, 'bus ' + name + ' write');
if (ctr.numSeries === 0) {
ctr.addSeries(new tr.model.CounterSeries('value',
tr.ui.b.getColorIdForGeneralPurposeString(
ctr.name + '.' + 'value')));
}
ctr.series.forEach(function(series) {
series.addCounterSample(ts, r_bw);
});
return true;
}
};
Parser.register(BusParser);
return {
BusParser: BusParser
};
});
</script>