[tick processor] Introduce --pairwise-timed-range processing mode
authorjkummerow <jkummerow@chromium.org>
Tue, 5 May 2015 14:15:07 +0000 (07:15 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 5 May 2015 14:17:48 +0000 (14:17 +0000)
Review URL: https://codereview.chromium.org/1123883002

Cr-Commit-Position: refs/heads/master@{#28228}

tools/logreader.js
tools/tickprocessor-driver.js
tools/tickprocessor.js

index ceac2b8..157a7fc 100644 (file)
  * @param {Array.<Object>} dispatchTable A table used for parsing and processing
  *     log records.
  * @param {boolean} timedRange Ignore ticks outside timed range.
+ * @param {boolean} pairwiseTimedRange Ignore ticks outside pairs of timer
+ *     markers.
  * @constructor
  */
-function LogReader(dispatchTable, timedRange) {
+function LogReader(dispatchTable, timedRange, pairwiseTimedRange) {
   /**
    * @type {Array.<Object>}
    */
@@ -50,6 +52,14 @@ function LogReader(dispatchTable, timedRange) {
   this.timedRange_ = timedRange;
 
   /**
+   * @type {boolean}
+   */
+  this.pairwiseTimedRange_ = pairwiseTimedRange;
+  if (pairwiseTimedRange) {
+    this.timedRange_ = true;
+  }
+
+  /**
    * Current line.
    * @type {number}
    */
@@ -109,6 +119,10 @@ LogReader.prototype.processLogLine = function(line) {
     if (this.hasSeenTimerMarker_) {
       this.processLog_(this.logLinesSinceLastTimerMarker_);
       this.logLinesSinceLastTimerMarker_ = [];
+      // In pairwise mode, a "current-time" line ends the timed range.
+      if (this.pairwiseTimedRange_) {
+        this.hasSeenTimerMarker_ = false;
+      }
     } else {
       this.hasSeenTimerMarker_ = true;
     }
index 1605418..946f543 100644 (file)
@@ -76,6 +76,7 @@ var tickProcessor = new TickProcessor(
   params.distortion,
   params.range,
   sourceMap,
-  params.timedRange);
+  params.timedRange,
+  params.pairwiseTimedRange);
 tickProcessor.processLogFile(params.logFileName);
 tickProcessor.printStatistics();
index 05f4207..d857573 100644 (file)
@@ -155,7 +155,8 @@ function TickProcessor(
     distortion,
     range,
     sourceMap,
-    timedRange) {
+    timedRange,
+    pairwiseTimedRange) {
   LogReader.call(this, {
       'shared-library': { parsers: [null, parseInt, parseInt],
           processor: this.processSharedLibrary },
@@ -193,7 +194,8 @@ function TickProcessor(
       'code-allocate': null,
       'begin-code-region': null,
       'end-code-region': null },
-      timedRange);
+      timedRange,
+      pairwiseTimedRange);
 
   this.cppEntriesProvider_ = cppEntriesProvider;
   this.callGraphSize_ = callGraphSize;
@@ -880,13 +882,16 @@ function ArgumentsProcessor(args) {
     '--source-map': ['sourceMap', null,
         'Specify the source map that should be used for output'],
     '--timed-range': ['timedRange', true,
-        'Ignore ticks before first and after last Date.now() call']
+        'Ignore ticks before first and after last Date.now() call'],
+    '--pairwise-timed-range': ['pairwiseTimedRange', true,
+        'Ignore ticks outside pairs of Date.now() calls']
   };
   this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
   this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
   this.argsDispatch_['--compiler'] = this.argsDispatch_['-c'];
   this.argsDispatch_['--other'] = this.argsDispatch_['-o'];
   this.argsDispatch_['--external'] = this.argsDispatch_['-e'];
+  this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range'];
 };
 
 
@@ -902,17 +907,18 @@ ArgumentsProcessor.DEFAULTS = {
   nm: 'nm',
   range: 'auto,auto',
   distortion: 0,
-  timedRange: false
+  timedRange: false,
+  pairwiseTimedRange: false
 };
 
 
 ArgumentsProcessor.prototype.parse = function() {
   while (this.args_.length) {
-    var arg = this.args_[0];
+    var arg = this.args_.shift();
     if (arg.charAt(0) != '-') {
-      break;
+      this.result_.logFileName = arg;
+      continue;
     }
-    this.args_.shift();
     var userValue = null;
     var eqPos = arg.indexOf('=');
     if (eqPos != -1) {
@@ -926,10 +932,6 @@ ArgumentsProcessor.prototype.parse = function() {
       return false;
     }
   }
-
-  if (this.args_.length >= 1) {
-      this.result_.logFileName = this.args_.shift();
-  }
   return true;
 };
 
@@ -954,15 +956,15 @@ ArgumentsProcessor.prototype.printUsageAndExit = function() {
         ArgumentsProcessor.DEFAULTS.logFileName + '".\n');
   print('Options:');
   for (var arg in this.argsDispatch_) {
-    var synonims = [arg];
+    var synonyms = [arg];
     var dispatch = this.argsDispatch_[arg];
     for (var synArg in this.argsDispatch_) {
       if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
-        synonims.push(synArg);
+        synonyms.push(synArg);
         delete this.argsDispatch_[synArg];
       }
     }
-    print('  ' + padRight(synonims.join(', '), 20) + dispatch[2]);
+    print('  ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]);
   }
   quit(2);
 };