Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / importer / linux_perf / clock_parser.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2012 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
20   var Parser = tracing.importer.linux_perf.Parser;
21
22   /**
23    * Parses linux trace mark events that were inserted in the trace by userland.
24    * @constructor
25    */
26   function ClockParser(importer) {
27     Parser.call(this, importer);
28
29     importer.registerEventHandler('clock_set_rate',
30         ClockParser.prototype.traceMarkWriteClockEvent.bind(this));
31
32     this.model_ = importer.model_;
33     this.ppids_ = {};
34   }
35
36   ClockParser.prototype = {
37     __proto__: Parser.prototype,
38
39     traceMarkWriteClockEvent: function(eventName, cpuNumber, pid, ts,
40                                        eventBase, threadName) {
41       var event = /(\S+) state=(\d+) cpu_id=(\d+)/.exec(eventBase.details);
42
43
44       var name = event[1];
45       var rate = parseInt(event[2]);
46
47       var ctr = this.model_.getOrCreateProcess(0)
48               .getOrCreateCounter(null, name);
49       // Initialize the counter's series fields if needed.
50       if (ctr.numSeries === 0) {
51         ctr.addSeries(new tracing.trace_model.CounterSeries('value',
52             tv.ui.getStringColorId(ctr.name + '.' + 'value')));
53       }
54       ctr.series.forEach(function(series) {
55         series.addCounterSample(ts, rate);
56       });
57
58       return true;
59     }
60   };
61
62   Parser.registerSubtype(ClockParser);
63
64   return {
65     ClockParser: ClockParser
66   };
67 });
68 </script>