Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if (process.platform === 'darwin') {
tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function() {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
${script}
})()`;
eval(script);
24 changes: 24 additions & 0 deletions test/tick-processor/test-tick-processor-preprocess-flag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');

if (!common.enoughTestCpu)
common.skip('test is CPU-intensive');

if (common.isWindows ||
common.isSunOS ||
common.isAIX ||
common.isLinuxPPCBE ||
common.isFreeBSD)
common.skip('C++ symbols are not mapped for this os.');

const base = require('./tick-processor-base.js');

base.runTest({
pattern: /^{/,
code: `function f() {
require('vm').runInDebugContext('Debug');
setImmediate(function() { f(); });
};
f();`,
profProcessFlags: ['--preprocess']
});
6 changes: 4 additions & 2 deletions test/tick-processor/tick-processor-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ function runTest(test) {

// Try to match after timeout
setTimeout(() => {
match(test.pattern, proc, () => ticks);
match(test.pattern, proc, () => ticks, test.profProcessFlags);
}, RETRY_TIMEOUT);
}

function match(pattern, parent, ticks) {
function match(pattern, parent, ticks, flags = []) {
// Store current ticks log
fs.writeFileSync(LOG_FILE, ticks());

const proc = cp.spawn(process.execPath, [
'--prof-process',
'--call-graph-size=10',
...flags,
LOG_FILE
], {
stdio: [ 'ignore', 'pipe', 'inherit' ]
});

let out = '';

proc.stdout.on('data', (chunk) => out += chunk);
proc.stdout.once('end', () => {
proc.once('exit', () => {
Expand Down