@samitouri / QOS-React-2 / commits / 901139c291

[scheduler][profiler] Start time of delayed tasks (#16809)

Fixes a bug in the Scheduler profiler where the start time of a delayed tasks is always 0.

Andrew Clark committed Sep 17, 2019 at 10:24 UTC 901139c2910d0dc33f07f85c748c64371f8664f4
2 files changed +27 -1
packages/scheduler/src/Scheduler.js
+1 -1
@@ -91,7 +91,7 @@ function advanceTimers(currentTime) {
91 timer.sortIndex = timer.expirationTime;
92 push(taskQueue, timer);
93 if (enableProfiling) {
94 - markTaskStart(timer);
94 + markTaskStart(timer, currentTime);
95 timer.isQueued = true;
96 }
97 } else {
packages/scheduler/src/__tests__/SchedulerProfiling-test.js
+26
@@ -483,6 +483,32 @@ Task 2 [Normal] │ ░░░░░░░░🡐 canceled
483 );
484 });
485
486 + it('handles delayed tasks', () => {
487 + Scheduler.unstable_Profiling.startLoggingProfilingEvents();
488 + scheduleCallback(
489 + NormalPriority,
490 + () => {
491 + Scheduler.unstable_advanceTime(1000);
492 + Scheduler.unstable_yieldValue('A');
493 + },
494 + {
495 + delay: 1000,
496 + },
497 + );
498 + expect(Scheduler).toFlushWithoutYielding();
499 +
500 + Scheduler.unstable_advanceTime(1000);
501 +
502 + expect(Scheduler).toFlushAndYield(['A']);
503 +
504 + expect(stopProfilingAndPrintFlamegraph()).toEqual(
505 + `
506 +!!! Main thread │████████████████████░░░░░░░░░░░░░░░░░░░░
507 +Task 1 [Normal] │ ████████████████████
508 +`,
509 + );
510 + });
511 +
512 it('handles cancelling a delayed task', () => {
513 Scheduler.unstable_Profiling.startLoggingProfilingEvents();
514 const task = scheduleCallback(