@@ -103,13 +103,16 @@ export function stopLoggingProfilingEvents(): ArrayBuffer | null {
103
103
104
104
export function markTaskStart (
105
105
task : { id : number , priorityLevel : PriorityLevel } ,
106
- time : number ,
106
+ ms : number ,
107
107
) {
108
108
if ( enableProfiling ) {
109
109
profilingState [ QUEUE_SIZE ] ++ ;
110
110
111
111
if ( eventLog !== null ) {
112
- logEvent ( [ TaskStartEvent , time , task . id , task . priorityLevel ] ) ;
112
+ // performance.now returns a float, representing milliseconds. When the
113
+ // event is logged, it's coerced to an int. Convert to microseconds to
114
+ // maintain extra degrees of precision.
115
+ logEvent ( [ TaskStartEvent , ms * 1000 , task . id , task . priorityLevel ] ) ;
113
116
}
114
117
}
115
118
}
@@ -119,15 +122,15 @@ export function markTaskCompleted(
119
122
id : number ,
120
123
priorityLevel : PriorityLevel ,
121
124
} ,
122
- time : number ,
125
+ ms : number ,
123
126
) {
124
127
if ( enableProfiling ) {
125
128
profilingState [ PRIORITY ] = NoPriority ;
126
129
profilingState [ CURRENT_TASK_ID ] = 0 ;
127
130
profilingState [ QUEUE_SIZE ] -- ;
128
131
129
132
if ( eventLog !== null ) {
130
- logEvent ( [ TaskCompleteEvent , time , task . id ] ) ;
133
+ logEvent ( [ TaskCompleteEvent , ms * 1000 , task . id ] ) ;
131
134
}
132
135
}
133
136
}
@@ -137,13 +140,13 @@ export function markTaskCanceled(
137
140
id : number ,
138
141
priorityLevel : PriorityLevel ,
139
142
} ,
140
- time : number ,
143
+ ms : number ,
141
144
) {
142
145
if ( enableProfiling ) {
143
146
profilingState [ QUEUE_SIZE ] -- ;
144
147
145
148
if ( eventLog !== null ) {
146
- logEvent ( [ TaskCancelEvent , time , task . id ] ) ;
149
+ logEvent ( [ TaskCancelEvent , ms * 1000 , task . id ] ) ;
147
150
}
148
151
}
149
152
}
@@ -153,22 +156,22 @@ export function markTaskErrored(
153
156
id : number ,
154
157
priorityLevel : PriorityLevel ,
155
158
} ,
156
- time : number ,
159
+ ms : number ,
157
160
) {
158
161
if ( enableProfiling ) {
159
162
profilingState [ PRIORITY ] = NoPriority ;
160
163
profilingState [ CURRENT_TASK_ID ] = 0 ;
161
164
profilingState [ QUEUE_SIZE ] -- ;
162
165
163
166
if ( eventLog !== null ) {
164
- logEvent ( [ TaskErrorEvent , time , task . id ] ) ;
167
+ logEvent ( [ TaskErrorEvent , ms * 1000 , task . id ] ) ;
165
168
}
166
169
}
167
170
}
168
171
169
172
export function markTaskRun (
170
173
task : { id : number , priorityLevel : PriorityLevel } ,
171
- time : number ,
174
+ ms : number ,
172
175
) {
173
176
if ( enableProfiling ) {
174
177
runIdCounter ++ ;
@@ -178,37 +181,37 @@ export function markTaskRun(
178
181
profilingState [ CURRENT_RUN_ID ] = runIdCounter ;
179
182
180
183
if ( eventLog !== null ) {
181
- logEvent ( [ TaskRunEvent , time , task . id , runIdCounter ] ) ;
184
+ logEvent ( [ TaskRunEvent , ms * 1000 , task . id , runIdCounter ] ) ;
182
185
}
183
186
}
184
187
}
185
188
186
- export function markTaskYield ( task : { id : number } , time : number ) {
189
+ export function markTaskYield ( task : { id : number } , ms : number ) {
187
190
if ( enableProfiling ) {
188
191
profilingState [ PRIORITY ] = NoPriority ;
189
192
profilingState [ CURRENT_TASK_ID ] = 0 ;
190
193
profilingState [ CURRENT_RUN_ID ] = 0 ;
191
194
192
195
if ( eventLog !== null ) {
193
- logEvent ( [ TaskYieldEvent , time , task . id , runIdCounter ] ) ;
196
+ logEvent ( [ TaskYieldEvent , ms * 1000 , task . id , runIdCounter ] ) ;
194
197
}
195
198
}
196
199
}
197
200
198
- export function markSchedulerSuspended ( time : number ) {
201
+ export function markSchedulerSuspended ( ms : number ) {
199
202
if ( enableProfiling ) {
200
203
mainThreadIdCounter ++ ;
201
204
202
205
if ( eventLog !== null ) {
203
- logEvent ( [ SchedulerSuspendEvent , time , mainThreadIdCounter ] ) ;
206
+ logEvent ( [ SchedulerSuspendEvent , ms * 1000 , mainThreadIdCounter ] ) ;
204
207
}
205
208
}
206
209
}
207
210
208
- export function markSchedulerUnsuspended ( time : number ) {
211
+ export function markSchedulerUnsuspended ( ms : number ) {
209
212
if ( enableProfiling ) {
210
213
if ( eventLog !== null ) {
211
- logEvent ( [ SchedulerResumeEvent , time , mainThreadIdCounter ] ) ;
214
+ logEvent ( [ SchedulerResumeEvent , ms * 1000 , mainThreadIdCounter ] ) ;
212
215
}
213
216
}
214
217
}
0 commit comments