@@ -71,7 +71,6 @@ const {
7171 validateObject,
7272 validateNumber,
7373} = require ( 'internal/validators' ) ;
74- let normalizeHeapProfileOptions ;
7574const {
7675 throwIfBuildingSnapshot,
7776} = require ( 'internal/v8/startup_snapshot' ) ;
@@ -111,6 +110,8 @@ const dc = require('diagnostics_channel');
111110const workerThreadsChannel = dc . channel ( 'worker_threads' ) ;
112111
113112let cwdCounter ;
113+ let normalizeHeapProfileOptions ;
114+ let normalizeCpuProfileOptions ;
114115
115116const environmentData = new SafeMap ( ) ;
116117
@@ -574,9 +575,16 @@ class Worker extends EventEmitter {
574575 } ) ;
575576 }
576577
577- // TODO(theanarkh): add options, such as sample_interval, CpuProfilingMode
578- startCpuProfile ( ) {
579- const startTaker = this [ kHandle ] ?. startCpuProfile ( ) ;
578+ startCpuProfile ( options ) {
579+ normalizeCpuProfileOptions ??=
580+ require ( 'internal/v8/cpu_profiler' ) . normalizeCpuProfileOptions ;
581+ const {
582+ samplingIntervalMicros,
583+ maxSamples,
584+ } = normalizeCpuProfileOptions ( options ) ;
585+ const startTaker = this [ kHandle ] ?. startCpuProfile (
586+ samplingIntervalMicros ,
587+ maxSamples ) ;
580588 return new Promise ( ( resolve , reject ) => {
581589 if ( ! startTaker ) return reject ( new ERR_WORKER_NOT_RUNNING ( ) ) ;
582590 startTaker . ondone = ( err , id ) => {
0 commit comments