(options = kEmptyObject)
| 16 | const kMaxSamplesUnlimited = 0xFFFF_FFFF; |
| 17 | |
| 18 | function 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 | |
| 55 | module.exports = { |
| 56 | normalizeCpuProfileOptions, |
no outgoing calls
no test coverage detected
searching dependent graphs…