mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
e0e3084482
This patch introduces a CLI flag --cpu-prof that starts the V8 CPU profiler on start up, and ends the profiler then writes the CPU profile before the Node.js instance (on the main thread or the worker thread) exits. By default the profile is written to `${cwd}/CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`. The patch also introduces a --cpu-prof-path flag for the user to specify the path the profile will be written to. Refs: https://github.com/nodejs/node/issues/26878 PR-URL: https://github.com/nodejs/node/pull/27147 Reviewed-By: Anna Henningsen <anna@addaleax.net>
8 lines
179 B
JavaScript
8 lines
179 B
JavaScript
'use strict';
|
|
function fib(n) {
|
|
if (n === 0 || n === 1) return n;
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
fib(parseInt(process.argv[2]) || 35);
|
|
process.kill(process.pid, "SIGINT");
|