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<link rel="import" href="/tracing/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 */ 18tr.exportTo('tr.e.importer.linux_perf', function() { 19 20 var ColorScheme = tr.b.ColorScheme; 21 var Parser = tr.e.importer.linux_perf.Parser; 22 23 /** 24 * Parses linux trace mark events that were inserted in the trace by userland. 25 * @constructor 26 */ 27 function ClockParser(importer) { 28 Parser.call(this, importer); 29 30 importer.registerEventHandler('clock_set_rate', 31 ClockParser.prototype.traceMarkWriteClockEvent.bind(this)); 32 33 this.model_ = importer.model_; 34 this.ppids_ = {}; 35 } 36 37 ClockParser.prototype = { 38 __proto__: Parser.prototype, 39 40 traceMarkWriteClockEvent: function(eventName, cpuNumber, pid, ts, 41 eventBase, threadName) { 42 var event = /(\S+) state=(\d+) cpu_id=(\d+)/.exec(eventBase.details); 43 44 45 var name = event[1]; 46 var rate = parseInt(event[2]); 47 48 var ctr = this.model_.kernel 49 .getOrCreateCounter(null, name); 50 // Initialize the counter's series fields if needed. 51 if (ctr.numSeries === 0) { 52 ctr.addSeries(new tr.model.CounterSeries('value', 53 ColorScheme.getColorIdForGeneralPurposeString( 54 ctr.name + '.' + 'value'))); 55 } 56 ctr.series.forEach(function(series) { 57 series.addCounterSample(ts, rate); 58 }); 59 60 return true; 61 } 62 }; 63 64 Parser.register(ClockParser); 65 66 return { 67 ClockParser: ClockParser 68 }; 69}); 70</script> 71