lib/third_party/tracing/extras/importer/trace_event_importer.js
function(event) {
      var ctr_name;
      if (event.id !== undefined)
        ctr_name = event.name + '[' + event.id + ']';
      else
        ctr_name = event.name;

      var ctr = this.model_.getOrCreateProcess(event.pid)
          .getOrCreateCounter(event.cat, ctr_name);
      var reservedColorId = event.cname ? getEventColor(event) : undefined;

      // Initialize the counter's series fields if needed.
      if (ctr.numSeries === 0) {
        for (var seriesName in event.args) {
          var colorId = reservedColorId ||
              getEventColor(event, ctr.name + '.' + seriesName);
          ctr.addSeries(new tr.model.CounterSeries(seriesName, colorId));
        }

        if (ctr.numSeries === 0) {
          this.model_.importWarning({
            type: 'counter_parse_error',
            message: 'Expected counter ' + event.name +
                ' to have at least one argument to use as a value.'
          });

          // Drop the counter.
          delete ctr.parent.counters[ctr.name];
          return;
        }
      }

      var ts = timestampFromUs(event.ts);
      ctr.series.forEach(function(series) {
        var val = event.args[series.name] ? event.args[series.name] : 0;
        series.addCounterSample(ts, val);
      });
    }
function(event) {
      var ctr_name;
      if (event.id !== undefined)
        ctr_name = event.name + '[' + event.id + ']';
      else
        ctr_name = event.name;

      var ctr = this.model_.getOrCreateProcess(event.pid)
          .getOrCreateCounter(event.cat, ctr_name);
      var reservedColorId = event.cname ? getEventColor(event) : undefined;

      // Initialize the counter's series fields if needed.
      if (ctr.numSeries === 0) {
        for (var seriesName in event.args) {
          var colorId = reservedColorId ||
              getEventColor(event, ctr.name + '.' + seriesName);
          ctr.addSeries(new tr.model.CounterSeries(seriesName, colorId));
        }

        if (ctr.numSeries === 0) {
          this.model_.importWarning({
            type: 'counter_parse_error',
            message: 'Expected counter ' + event.name +
                ' to have at least one argument to use as a value.'
          });

          // Drop the counter.
          delete ctr.parent.counters[ctr.name];
          return;
        }
      }

      var ts = timestampFromUs(event.ts);
      ctr.series.forEach(function(series) {
        var val = event.args[series.name] ? event.args[series.name] : 0;
        series.addCounterSample(ts, val);
      });
    }
function ( event ) { var ctr_name ; if ( event . id !== undefined ) ctr_name = event . name + '[' + event . id + ']' ; else ctr_name = event . name ; var ctr = this . model_ . getOrCreateProcess ( event . pid ) . getOrCreateCounter ( event . cat , ctr_name ) ; var reservedColorId = event . cname ? getEventColor ( event ) : undefined ; // Initialize the counter's series fields if needed. if ( ctr . numSeries === 0 ) { for ( var seriesName in event . args ) { var colorId = reservedColorId || getEventColor ( event , ctr . name + '.' + seriesName ) ; ctr . addSeries ( new tr . model . CounterSeries ( seriesName , colorId ) ) ; } if ( ctr . numSeries === 0 ) { this . model_ . importWarning ( { type : 'counter_parse_error' , message : 'Expected counter ' + event . name + ' to have at least one argument to use as a value.' } ) ; // Drop the counter. delete ctr . parent . counters [ ctr . name ] ; return ; } } var ts = timestampFromUs ( event . ts ) ; ctr . series . forEach ( function ( series ) { var val = event . args [ series . name ] ? event . args [ series . name ] : 0 ; series . addCounterSample ( ts , val ) ; } ) ; }
Helper that creates and adds samples to a Counter object based on
'C' phase events.
Helper that creates and adds samples to a Counter object based on C phase events .