MCPcopy Index your code
hub / github.com/nodejs/node / normalizeCpuProfileOptions

Function normalizeCpuProfileOptions

lib/internal/v8/cpu_profiler.js:18–53  ·  view source on GitHub ↗
(options = kEmptyObject)

Source from the content-addressed store, hash-verified

16const kMaxSamplesUnlimited = 0xFFFF_FFFF;
17
18function normalizeCpuProfileOptions(options = kEmptyObject) {
19 validateObject(options, 'options');
20
21 // TODO(ishabi): add support for 'mode' and 'filterContext' options
22 const {
23 sampleInterval,
24 maxBufferSize,
25 } = options;
26
27 let samplingIntervalMicros = 0;
28 if (sampleInterval !== undefined) {
29 validateNumber(sampleInterval,
30 'options.sampleInterval',
31 0,
32 kMaxSamplingIntervalMs);
33 samplingIntervalMicros = MathFloor(sampleInterval * kMicrosPerMilli);
34 if (sampleInterval > 0 && samplingIntervalMicros === 0) {
35 samplingIntervalMicros = 1;
36 }
37 }
38
39 const size = maxBufferSize;
40 let normalizedMaxSamples = kMaxSamplesUnlimited;
41 if (size !== undefined) {
42 validateNumber(size,
43 'options.maxBufferSize',
44 1,
45 kMaxSamplesUnlimited);
46 normalizedMaxSamples = MathFloor(size);
47 }
48
49 return {
50 samplingIntervalMicros,
51 maxSamples: normalizedMaxSamples,
52 };
53}
54
55module.exports = {
56 normalizeCpuProfileOptions,

Callers 2

startCpuProfileFunction · 0.85
startCpuProfileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…