Comparing version 4.10.2 to 4.11.0
@@ -63,2 +63,3 @@ #!/usr/bin/env node | ||
collectOnly: 'collect-only', | ||
collectDelay: 'collect-delay', | ||
kernelTracing: 'kernel-tracing', | ||
@@ -65,0 +66,0 @@ kernelTracingDebug: 'kernel-tracing-debug', |
@@ -62,2 +62,8 @@ # Programmatic API | ||
#### `collectDelay` (number) | ||
Specify a delay(ms) before collecting data. | ||
Default: 0 | ||
#### `mapFrames` (function) | ||
@@ -64,0 +70,0 @@ |
@@ -37,3 +37,3 @@ # UI | ||
Posssible `{tag}` values are covered in the buttons listed under [Tiers](#tiers). | ||
Possible `{tag}` values are covered in the buttons listed under [Tiers](#tiers). | ||
@@ -76,3 +76,3 @@ ## Buttons | ||
Pressing the Tiers button will result in the categories being highlighted | ||
according to the colouring of the category buttons, | ||
according to the colouring of the category buttons as follows. | ||
@@ -168,2 +168,2 @@ #### app | ||
Disabled by default. | ||
Disabled by default. |
10
index.js
@@ -28,4 +28,6 @@ 'use strict' | ||
args.collectDelay = args.collectDelay || 0 | ||
validate(args) | ||
const { collectOnly, visualizeOnly, writeTicks, treeDebug, mapFrames, visualizeCpuProfile } = args | ||
const { collectOnly, visualizeOnly, writeTicks, treeDebug, mapFrames, visualizeCpuProfile, collectDelay } = args | ||
@@ -67,2 +69,6 @@ let incompatibleOptions = 0 | ||
if (collectDelay) { | ||
debug('data collection will be delayed by ' + collectDelay + ' ms') | ||
} | ||
try { | ||
@@ -150,3 +156,3 @@ const file = generateFlamegraph({ ...args, ticks, inlined, pid, folder }) | ||
const ticks = (srcType === 'v8') | ||
? await v8LogToTicks(src, pathToNodeBinary) | ||
? await v8LogToTicks(src, { pathToNodeBinary }) | ||
: traceStacksToTicks(src) | ||
@@ -153,0 +159,0 @@ |
@@ -18,5 +18,5 @@ 'use strict' | ||
async function wrapper (isolateLogPath, node) { | ||
async function wrapper (isolateLogPath, options) { | ||
const normalised = await prepareForPreprocess(isolateLogPath) | ||
return v8LogToTicks(normalised, node) | ||
return v8LogToTicks(normalised, options) | ||
} | ||
@@ -71,5 +71,5 @@ | ||
function v8LogToTicks (isolateLogPath, node) { | ||
function v8LogToTicks (isolateLogPath, options) { | ||
const isJson = extname(isolateLogPath) === '.json' | ||
const sp = isJson || spawn(node, [ | ||
const sp = isJson || spawn(options.pathToNodeBinary, [ | ||
'--prof-process', '--preprocess', isolateLogPath | ||
@@ -124,6 +124,14 @@ ], { stdio: ['ignore', 'pipe', 'pipe'] }) | ||
const firstTick = [] | ||
const delayMs = options.collectDelay * 1000 | ||
const tickStream = parse('ticks.*', (tick) => { | ||
const addr = tick.s.filter((n, i) => i % 2 === 0) | ||
var stack = addr.map((n) => codes[n]).filter(Boolean) | ||
ticks.push(stack.reverse()) | ||
if (firstTick.length === 0) { | ||
firstTick.push(tick.tm) | ||
} | ||
// Compare ticks to first for collectDelay | ||
if (tick.tm > (firstTick[0] + delayMs)) { | ||
ticks.push(stack.reverse()) | ||
} | ||
}) | ||
@@ -130,0 +138,0 @@ |
{ | ||
"name": "0x", | ||
"version": "4.10.2", | ||
"version": "4.11.0", | ||
"description": "🔥 single-command flamegraph profiling 🔥", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,3 +24,3 @@ 'use strict' | ||
async function v8 (args) { | ||
const { status, outputDir, workingDir, name, onPort, pathToNodeBinary } = args | ||
const { status, outputDir, workingDir, name, onPort, pathToNodeBinary, collectDelay } = args | ||
@@ -118,3 +118,3 @@ let proc = spawn(pathToNodeBinary, [ | ||
return { | ||
ticks: await v8LogToTicks(isolateLogPath, pathToNodeBinary), | ||
ticks: await v8LogToTicks(isolateLogPath, { pathToNodeBinary, collectDelay }), | ||
inlined: inlined, | ||
@@ -121,0 +121,0 @@ pid: proc.pid, |
@@ -229,2 +229,8 @@ # 0x | ||
### --collect-delay | ||
Delay the collection of stacks by a specified time(ms) relative to the first entry. | ||
Default: 0 | ||
### --visualize-only | ||
@@ -231,0 +237,0 @@ |
@@ -104,2 +104,8 @@ { | ||
}, | ||
"collect-delay": { | ||
"type": "number" | ||
}, | ||
"collectDelay": { | ||
"type": "number" | ||
}, | ||
"kernelTracing": { | ||
@@ -106,0 +112,0 @@ "type": "boolean" |
@@ -69,2 +69,5 @@ --open | -o Automatically open after finishing | ||
--collect-delay Specify a delay(ms) before collecting data. | ||
--visualize-only <dir> Build or rebuild flamegraph using the output dir. | ||
@@ -71,0 +74,0 @@ Counterpart to --collect-only. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100920
2028
334