Skip to content

Commit

Permalink
🧪 improve runPostTask() method
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Feb 5, 2024
1 parent 0df5084 commit 5cc7430
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions playground/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ document.querySelector('#post-task-background')!.addEventListener('click', () =>
})

async function runPostTask(priority: 'user-blocking' | 'user-visible' | 'background') {
for (let i = 0; i < 5; i++) {
const totalTime = 1000
const singleTaskTime = 2
const iterations = Math.round(totalTime / singleTaskTime)
for (let i = 0; i < iterations; i++) {
// @ts-ignore
scheduler.postTask(
() => {
const start = Date.now()
while (Date.now() - start < 200) {}
while (Date.now() - start < singleTaskTime) {}
},
{
priority,
Expand Down

0 comments on commit 5cc7430

Please sign in to comment.