1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @fileoverview Parses trace_marker events that were inserted in the trace by 7 * userland. 8 */ 9 base.require('importer.linux_perf.parser'); 10 base.exportTo('tracing.importer.linux_perf', function() { 11 12 var Parser = tracing.importer.linux_perf.Parser; 13 14 /** 15 * Parses linux trace mark events that were inserted in the trace by userland. 16 * @constructor 17 */ 18 function ClockParser(importer) { 19 Parser.call(this, importer); 20 21 importer.registerEventHandler('clock_set_rate', 22 ClockParser.prototype.traceMarkWriteClockEvent.bind(this)); 23 24 this.model_ = importer.model_; 25 this.ppids_ = {}; 26 } 27 28 ClockParser.prototype = { 29 __proto__: Parser.prototype, 30 31 traceMarkWriteClockEvent: function(eventName, cpuNumber, pid, ts, 32 eventBase, threadName) { 33 var event = /(\S+) state=(\d+) cpu_id=(\d+)/.exec(eventBase.details); 34 35 36 var name = event[1]; 37 var rate = parseInt(event[2]); 38 39 var ctr = this.model_.getOrCreateProcess(0) 40 .getOrCreateCounter(null, name); 41 // Initialize the counter's series fields if needed. 42 if (ctr.numSeries == 0) { 43 ctr.seriesNames.push('value'); 44 ctr.seriesColors.push( 45 tracing.getStringColorId(ctr.name + '.' + 'value')); 46 } 47 48 // Add the sample value. 49 ctr.timestamps.push(ts); 50 ctr.samples.push(rate); 51 52 return true; 53 }, 54 }; 55 56 Parser.registerSubtype(ClockParser); 57 58 return { 59 ClockParser: ClockParser 60 }; 61 }); 62