@@ -169,7 +169,7 @@ describe('Profiler Integration', () => {
169169
170170 it ( 'should create proper DevTools payloads for tracks' , ( ) => {
171171 profiler . measure ( 'track-test' , ( ) : string => 'result' , {
172- success : ( result : string ) => ( {
172+ success : result => ( {
173173 properties : [ [ 'result' , result ] ] ,
174174 tooltipText : 'Track test completed' ,
175175 } ) ,
@@ -196,8 +196,8 @@ describe('Profiler Integration', () => {
196196 } ) ;
197197
198198 it ( 'should merge track defaults with measurement options' , ( ) => {
199- profiler . measure ( 'sync-op' , ( ) : string => 'sync-result' , {
200- success : ( result : string ) => ( {
199+ profiler . measure ( 'sync-op' , ( ) => 'sync-result' , {
200+ success : result => ( {
201201 properties : [
202202 [ 'operation' , 'sync' ] ,
203203 [ 'result' , result ] ,
@@ -279,6 +279,24 @@ describe('Profiler Integration', () => {
279279 ] ) ,
280280 ) ;
281281 } ) ;
282+
283+ it ( 'should not create performance entries when disabled' , async ( ) => {
284+ profiler . setEnabled ( false ) ;
285+
286+ const syncResult = profiler . measure ( 'disabled-sync' , ( ) => 'sync' ) ;
287+ expect ( syncResult ) . toBe ( 'sync' ) ;
288+
289+ const asyncResult = profiler . measureAsync (
290+ 'disabled-async' ,
291+ async ( ) => 'async' ,
292+ ) ;
293+ await expect ( asyncResult ) . resolves . toBe ( 'async' ) ;
294+
295+ profiler . marker ( 'disabled-marker' ) ;
296+
297+ expect ( performance . getEntriesByType ( 'mark' ) ) . toHaveLength ( 0 ) ;
298+ expect ( performance . getEntriesByType ( 'measure' ) ) . toHaveLength ( 0 ) ;
299+ } ) ;
282300} ) ;
283301
284302describe ( 'NodeJS Profiler Integration' , ( ) => {
@@ -326,8 +344,8 @@ describe('NodeJS Profiler Integration', () => {
326344 } ) ;
327345
328346 it ( 'should disable profiling and close sink' , ( ) => {
329- nodejsProfiler . stop ( ) ;
330- expect ( nodejsProfiler . isRunning ( ) ) . toBe ( false ) ;
347+ nodejsProfiler . setEnabled ( false ) ;
348+ expect ( nodejsProfiler . isEnabled ( ) ) . toBe ( false ) ;
331349 expect ( mockSink . isClosed ( ) ) . toBe ( true ) ;
332350 expect ( mockSink . close ) . toHaveBeenCalledTimes ( 1 ) ;
333351
@@ -339,10 +357,10 @@ describe('NodeJS Profiler Integration', () => {
339357 } ) ;
340358
341359 it ( 'should re-enable profiling correctly' , ( ) => {
342- nodejsProfiler . stop ( ) ;
343- nodejsProfiler . start ( ) ;
360+ nodejsProfiler . setEnabled ( false ) ;
361+ nodejsProfiler . setEnabled ( true ) ;
344362
345- expect ( nodejsProfiler . isRunning ( ) ) . toBe ( true ) ;
363+ expect ( nodejsProfiler . isEnabled ( ) ) . toBe ( true ) ;
346364 expect ( mockSink . isClosed ( ) ) . toBe ( false ) ;
347365 expect ( mockSink . open ) . toHaveBeenCalledTimes ( 2 ) ;
348366
@@ -378,15 +396,15 @@ describe('NodeJS Profiler Integration', () => {
378396 enabled : true ,
379397 } ) ;
380398
381- const bufferedStats = bufferedProfiler . getStats ( ) ;
399+ const bufferedStats = bufferedProfiler . stats ;
382400 expect ( bufferedStats . state ) . toBe ( 'running' ) ;
383401 expect ( bufferedStats . walOpen ) . toBe ( true ) ;
384402 expect ( bufferedStats . isSubscribed ) . toBe ( true ) ;
385403 expect ( bufferedStats . queued ) . toBe ( 0 ) ;
386404 expect ( bufferedStats . dropped ) . toBe ( 0 ) ;
387405 expect ( bufferedStats . written ) . toBe ( 0 ) ;
388406
389- bufferedProfiler . stop ( ) ;
407+ bufferedProfiler . setEnabled ( false ) ;
390408 } ) ;
391409
392410 it ( 'should return correct getStats with dropped and written counts' , ( ) => {
@@ -402,15 +420,15 @@ describe('NodeJS Profiler Integration', () => {
402420
403421 expect ( statsProfiler . measure ( 'test-op' , ( ) => 'result' ) ) . toBe ( 'result' ) ;
404422
405- const stats = statsProfiler . getStats ( ) ;
423+ const stats = statsProfiler . stats ;
406424 expect ( stats . state ) . toBe ( 'running' ) ;
407425 expect ( stats . walOpen ) . toBe ( true ) ;
408426 expect ( stats . isSubscribed ) . toBe ( true ) ;
409427 expect ( typeof stats . queued ) . toBe ( 'number' ) ;
410428 expect ( typeof stats . dropped ) . toBe ( 'number' ) ;
411429 expect ( typeof stats . written ) . toBe ( 'number' ) ;
412430
413- statsProfiler . stop ( ) ;
431+ statsProfiler . setEnabled ( false ) ;
414432 } ) ;
415433
416434 it ( 'should provide comprehensive queue statistics via getStats' , ( ) => {
@@ -425,7 +443,7 @@ describe('NodeJS Profiler Integration', () => {
425443 } ) ;
426444
427445 // Initial stats should be zero
428- const initialStats = profiler . getStats ( ) ;
446+ const initialStats = profiler . stats ;
429447 expect ( initialStats . state ) . toBe ( 'running' ) ;
430448 expect ( initialStats . walOpen ) . toBe ( true ) ;
431449 expect ( initialStats . isSubscribed ) . toBe ( true ) ;
@@ -437,7 +455,7 @@ describe('NodeJS Profiler Integration', () => {
437455 profiler . measure ( 'operation-1' , ( ) => 'result1' ) ;
438456 profiler . measure ( 'operation-2' , ( ) => 'result2' ) ;
439457
440- const statsAfterMeasurements = profiler . getStats ( ) ;
458+ const statsAfterMeasurements = profiler . stats ;
441459
442460 // Verify all stats are present and are numbers
443461 expect ( typeof statsAfterMeasurements . queued ) . toBe ( 'number' ) ;
@@ -450,9 +468,9 @@ describe('NodeJS Profiler Integration', () => {
450468 expect ( statsAfterMeasurements . written ) . toBeGreaterThanOrEqual ( 0 ) ;
451469
452470 // Disable profiler to flush remaining items
453- profiler . stop ( ) ;
471+ profiler . setEnabled ( false ) ;
454472
455- const finalStats = profiler . getStats ( ) ;
473+ const finalStats = profiler . stats ;
456474 expect ( finalStats . state ) . toBe ( 'idle' ) ; // Should be idle
457475 expect ( finalStats . walOpen ) . toBe ( false ) ; // WAL should be closed when disabled
458476 expect ( finalStats . isSubscribed ) . toBe ( false ) ; // Should not be subscribed when disabled
0 commit comments