pm2-perfmonitor 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/perf-sampler.js +12 -7
- package/package.json +1 -1
package/lib/perf-sampler.js
CHANGED
|
@@ -25,10 +25,9 @@ const getExeca = async () => {
|
|
|
25
25
|
const execCommand = async (cmd, args, options = {}) => {
|
|
26
26
|
try {
|
|
27
27
|
const execa = await getExeca()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
28
|
+
|
|
29
|
+
await execa(cmd, args, options)
|
|
30
|
+
|
|
32
31
|
return true
|
|
33
32
|
} catch (err) {
|
|
34
33
|
console.error(`Command failed: ${cmd} ${args.join(' ')}`, err.message)
|
|
@@ -187,7 +186,9 @@ const performPerfSampling = async ({
|
|
|
187
186
|
|
|
188
187
|
// --- Step 2: perf script 导出为文本堆栈 ---
|
|
189
188
|
const scriptOk = await execCommand('perf', ['script', '-i', perfDataFile], {
|
|
190
|
-
stdout:
|
|
189
|
+
stdout: {
|
|
190
|
+
file: perfStacksFile,
|
|
191
|
+
},
|
|
191
192
|
})
|
|
192
193
|
|
|
193
194
|
if (!scriptOk) return
|
|
@@ -218,14 +219,18 @@ const performPerfSampling = async ({
|
|
|
218
219
|
stackcollapsePath,
|
|
219
220
|
[perfStacksFile],
|
|
220
221
|
{
|
|
221
|
-
stdout:
|
|
222
|
+
stdout: {
|
|
223
|
+
file: perfFoldedFile,
|
|
224
|
+
},
|
|
222
225
|
},
|
|
223
226
|
)
|
|
224
227
|
if (!collapseOk) return
|
|
225
228
|
|
|
226
229
|
// --- Step 5: 生成 SVG 火焰图 ---
|
|
227
230
|
const flameOk = await execCommand(flamegraphPath, [perfFoldedFile], {
|
|
228
|
-
stdout:
|
|
231
|
+
stdout: {
|
|
232
|
+
file: perfSvgFile,
|
|
233
|
+
},
|
|
229
234
|
})
|
|
230
235
|
if (flameOk) {
|
|
231
236
|
logger('info', `PID:${pidNum} Flame graph generated: ${perfSvgFile}`)
|