@@ -10,6 +10,7 @@ describe('epochClock', () => {
1010 expect ( c . fromEpochMs ) . toBeFunction ( ) ;
1111 expect ( c . fromEpochUs ) . toBeFunction ( ) ;
1212 expect ( c . fromPerfMs ) . toBeFunction ( ) ;
13+ expect ( c . fromEntry ) . toBeFunction ( ) ;
1314 expect ( c . fromEntryStartTimeMs ) . toBeFunction ( ) ;
1415 expect ( c . fromDateNowMs ) . toBeFunction ( ) ;
1516 } ) ;
@@ -72,6 +73,41 @@ describe('epochClock', () => {
7273 ] ) . toStrictEqual ( [ c . fromPerfMs ( 0 ) , c . fromPerfMs ( 1000 ) ] ) ;
7374 } ) ;
7475
76+ it ( 'should convert performance mark to microseconds' , ( ) => {
77+ const markEntry = {
78+ name : 'test-mark' ,
79+ entryType : 'mark' ,
80+ startTime : 1000 ,
81+ duration : 0 ,
82+ } as PerformanceMark ;
83+
84+ expect ( defaultClock . fromEntry ( markEntry ) ) . toBe (
85+ defaultClock . fromPerfMs ( 1000 ) ,
86+ ) ;
87+ expect ( defaultClock . fromEntry ( markEntry , true ) ) . toBe (
88+ defaultClock . fromPerfMs ( 1000 ) ,
89+ ) ; // useEndTime doesn't matter for marks
90+ } ) ;
91+
92+ it ( 'should convert performance measure to microseconds' , ( ) => {
93+ const measureEntry = {
94+ name : 'test-measure' ,
95+ entryType : 'measure' ,
96+ startTime : 1000 ,
97+ duration : 500 ,
98+ } as PerformanceMeasure ;
99+
100+ expect ( defaultClock . fromEntry ( measureEntry ) ) . toBe (
101+ defaultClock . fromPerfMs ( 1000 ) ,
102+ ) ; // useEndTime = false (default)
103+ expect ( defaultClock . fromEntry ( measureEntry , false ) ) . toBe (
104+ defaultClock . fromPerfMs ( 1000 ) ,
105+ ) ; // explicit false
106+ expect ( defaultClock . fromEntry ( measureEntry , true ) ) . toBe (
107+ defaultClock . fromPerfMs ( 1500 ) ,
108+ ) ; // useEndTime = true, adds duration
109+ } ) ;
110+
75111 it ( 'should convert Date.now() milliseconds to microseconds' , ( ) => {
76112 const c = epochClock ( ) ;
77113 expect ( [
0 commit comments