Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lib/input-perf.js: Add process name prefix

Add process name as a prefix to each stack frame. This is
useful to better distinguish between different processes calling
functions in the same shared library:

    bar (in process 'foo')

becomes:

    foo`bar

This brings the output of this reader more in line with the others.
  • Loading branch information...
commit c7b74373d99838f80e51d2fb46aa1a8d27ee9d29 1 parent e38c17b
@ackalker ackalker authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/input-perf.js
View
14 lib/input-perf.js
@@ -25,6 +25,7 @@ function PerfStreamReader(input, log)
{
this.dsr_log = log;
this.dsr_linenum = 0;
+ this.dsr_prefix = '';
this.dsr_stack = [];
this.dsr_carrier = mod_carrier.carry(input);
this.dsr_carrier.on('line', this.onLine.bind(this));
@@ -43,9 +44,12 @@ PerfStreamReader.prototype.onLine = function (line)
if (/^#/.exec(line))
return;
- /* Skip summary lines */
- if (/^\S+/.exec(line))
+ /* Get process name from summary line, to use as prefix */
+ var match = /(^\w+)\s+/.exec(line);
+ if (match) {
+ this.dsr_prefix = match[1];
return;
+ }
/*
* In general, lines may have leading or trailing whitespace and the
@@ -68,6 +72,7 @@ PerfStreamReader.prototype.onLine = function (line)
}
this.emit('stack', this.dsr_stack, 1);
+ this.dsr_prefix = '';
this.dsr_stack = [];
return;
}
@@ -90,6 +95,11 @@ PerfStreamReader.prototype.onLine = function (line)
return;
}
+ /* Add prefix */
+ if (this.dsr_prefix.length > 0) {
+ frame = this.dsr_prefix + '`' + frame;
+ }
+
this.dsr_stack.unshift(frame);
};
Please sign in to comment.
Something went wrong with that request. Please try again.