* Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details
(path, cb)
| 7097 | * See https://nodejs.org/api/inspector.html#inspector_example_usage for details |
| 7098 | */ |
| 7099 | function enableCPUProfiler(path, cb) { |
| 7100 | if (activeSession) { |
| 7101 | cb(); |
| 7102 | return false; |
| 7103 | } |
| 7104 | var inspector = require("inspector"); |
| 7105 | if (!inspector || !inspector.Session) { |
| 7106 | cb(); |
| 7107 | return false; |
| 7108 | } |
| 7109 | var session = new inspector.Session(); |
| 7110 | session.connect(); |
| 7111 | session.post("Profiler.enable", function () { |
| 7112 | session.post("Profiler.start", function () { |
| 7113 | activeSession = session; |
| 7114 | profilePath = path; |
| 7115 | cb(); |
| 7116 | }); |
| 7117 | }); |
| 7118 | return true; |
| 7119 | } |
| 7120 | /** |
| 7121 | * Strips non-TS paths from the profile, so users with private projects shouldn't |
| 7122 | * need to worry about leaking paths by submitting a cpu profile to us |