-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf_hooks,trace_events: emit perf milestone trace events
Emit the perf_hooks node timing milestones as trace events. PR-URL: #19175 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
Showing
7 changed files
with
92 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const tmpdir = require('../common/tmpdir'); | ||
|
||
const names = [ | ||
'environment', | ||
'nodeStart', | ||
'v8Start', | ||
'loopStart', | ||
'loopExit', | ||
'bootstrapComplete', | ||
'thirdPartyMainStart', | ||
'thirdPartyMainEnd', | ||
'clusterSetupStart', | ||
'clusterSetupEnd', | ||
'moduleLoadStart', | ||
'moduleLoadEnd', | ||
'preloadModulesLoadStart', | ||
'preloadModulesLoadEnd' | ||
]; | ||
|
||
if (process.argv[2] === 'child') { | ||
1 + 1; | ||
} else { | ||
tmpdir.refresh(); | ||
process.chdir(tmpdir.path); | ||
|
||
const proc = cp.fork(__filename, | ||
[ 'child' ], { | ||
execArgv: [ | ||
'--trace-events-enabled', | ||
'--trace-event-categories', | ||
'node.bootstrap' | ||
] | ||
}); | ||
|
||
proc.once('exit', common.mustCall(() => { | ||
const file = path.join(tmpdir.path, 'node_trace.1.log'); | ||
|
||
assert(common.fileExists(file)); | ||
fs.readFile(file, common.mustCall((err, data) => { | ||
const traces = JSON.parse(data.toString()).traceEvents; | ||
traces.forEach((trace) => { | ||
assert.strictEqual(trace.pid, proc.pid); | ||
assert(names.includes(trace.name)); | ||
}); | ||
})); | ||
})); | ||
} |