Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / importer / linux_perf / bus_parser.html
1 <!DOCTYPE html>
2 <!--
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.
6 -->
7
8 <link rel="import" href="/tracing/importer/linux_perf/parser.html">
9 <link rel="import" href="/tracing/trace_model/counter_series.html">
10
11 <script>
12 'use strict';
13
14 /**
15  * @fileoverview Parses trace_marker events that were inserted in the trace by
16  * userland.
17  */
18 tv.exportTo('tracing.importer.linux_perf', function() {
19   var Parser = tracing.importer.linux_perf.Parser;
20
21   /**
22    * Parses linux trace mark events that were inserted in the trace by userland.
23    * @constructor
24    */
25   function BusParser(importer) {
26     Parser.call(this, importer);
27
28     importer.registerEventHandler('memory_bus_usage',
29         BusParser.prototype.traceMarkWriteBusEvent.bind(this));
30
31     this.model_ = importer.model_;
32     this.ppids_ = {};
33   }
34
35   BusParser.prototype = {
36     __proto__: Parser.prototype,
37
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);
43
44       var name = event[1];
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]);
50
51       // BW in MB/s
52       var r_bw = r_bytes * 1000000000 / ns;
53       r_bw /= 1024 * 1024;
54       var w_bw = w_bytes * 1000000000 / ns;
55       w_bw /= 1024 * 1024;
56
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')));
62       }
63       ctr.series.forEach(function(series) {
64         series.addCounterSample(ts, r_bw);
65       });
66
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')));
72       }
73       ctr.series.forEach(function(series) {
74         series.addCounterSample(ts, r_bw);
75       });
76
77       return true;
78     }
79   };
80
81   Parser.registerSubtype(BusParser);
82
83   return {
84     BusParser: BusParser
85   };
86 });
87 </script>