• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<!--
3Copyright (c) 2012 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/extras/importer/linux_perf/parser.html">
9
10<script>
11'use strict';
12
13/**
14 * @fileoverview Parses exynos events in the Linux event trace format.
15 */
16tr.exportTo('tr.e.importer.linux_perf', function() {
17
18  var ColorScheme = tr.b.ColorScheme;
19  var Parser = tr.e.importer.linux_perf.Parser;
20
21  /**
22   * Parses linux exynos trace events.
23   * @constructor
24   */
25  function ExynosParser(importer) {
26    Parser.call(this, importer);
27
28    importer.registerEventHandler('exynos_busfreq_target_int',
29        ExynosParser.prototype.busfreqTargetIntEvent.bind(this));
30    importer.registerEventHandler('exynos_busfreq_target_mif',
31        ExynosParser.prototype.busfreqTargetMifEvent.bind(this));
32
33    importer.registerEventHandler('exynos_page_flip_state',
34        ExynosParser.prototype.pageFlipStateEvent.bind(this));
35  }
36
37  ExynosParser.prototype = {
38    __proto__: Parser.prototype,
39
40    exynosBusfreqSample: function(name, ts, frequency) {
41      var targetCpu = this.importer.getOrCreateCpu(0);
42      var counter = targetCpu.getOrCreateCounter('', name);
43      if (counter.numSeries === 0) {
44        counter.addSeries(new tr.model.CounterSeries('frequency',
45            ColorScheme.getColorIdForGeneralPurposeString(
46                counter.name + '.' + 'frequency')));
47      }
48      counter.series.forEach(function(series) {
49        series.addCounterSample(ts, frequency);
50      });
51    },
52
53    /**
54     * Parses exynos_busfreq_target_int events and sets up state.
55     */
56    busfreqTargetIntEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
57      var event = /frequency=(\d+)/.exec(eventBase.details);
58      if (!event)
59        return false;
60
61      this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1]));
62      return true;
63    },
64
65    /**
66     * Parses exynos_busfreq_target_mif events and sets up state.
67     */
68    busfreqTargetMifEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
69      var event = /frequency=(\d+)/.exec(eventBase.details);
70      if (!event)
71        return false;
72
73      this.exynosBusfreqSample('MIF Frequency', ts, parseInt(event[1]));
74      return true;
75    },
76
77    exynosPageFlipStateOpenSlice: function(ts, pipe, fb, state) {
78      var kthread = this.importer.getOrCreatePseudoThread(
79          'exynos_flip_state (pipe:' + pipe + ', fb:' + fb + ')');
80      kthread.openSliceTS = ts;
81      kthread.openSlice = state;
82    },
83
84    exynosPageFlipStateCloseSlice: function(ts, pipe, fb, args) {
85      var kthread = this.importer.getOrCreatePseudoThread(
86          'exynos_flip_state (pipe:' + pipe + ', fb:' + fb + ')');
87      if (kthread.openSlice) {
88        var slice = new tr.model.Slice('', kthread.openSlice,
89            ColorScheme.getColorIdForGeneralPurposeString(kthread.openSlice),
90            kthread.openSliceTS,
91            args,
92            ts - kthread.openSliceTS);
93        kthread.thread.sliceGroup.pushSlice(slice);
94      }
95      kthread.openSlice = undefined;
96    },
97
98    /**
99     * Parses page_flip_state events and sets up state in the importer.
100     */
101    pageFlipStateEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
102      var event = /pipe=(\d+), fb=(\d+), state=(.*)/.exec(eventBase.details);
103      if (!event)
104        return false;
105
106      var pipe = parseInt(event[1]);
107      var fb = parseInt(event[2]);
108      var state = event[3];
109
110      this.exynosPageFlipStateCloseSlice(ts, pipe, fb,
111          {
112            pipe: pipe,
113            fb: fb
114          });
115      if (state !== 'flipped')
116        this.exynosPageFlipStateOpenSlice(ts, pipe, fb, state);
117      return true;
118    }
119  };
120
121  Parser.register(ExynosParser);
122
123  return {
124    ExynosParser: ExynosParser
125  };
126});
127</script>
128
129