Skip to content

Commit

Permalink
another test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0ursTruly committed Jun 22, 2024
1 parent 2e6f91c commit 691c57c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# timer
custom and more accurate setInterval and setTimeout functionality that is not nerfed for things like when the browser tab is not in focus

![alt text](image.png)
Binary file added image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 23 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,27 @@ const test=require('node:test'), assert=require('node:assert'), timer=require('.
},5e3)
return await p
})
process.exit(0)
await test("2) Several Intervals Skill Gap",async function(){
let resolve=null, p=new Promise(r=>resolve=r)
let p1=0, p2=0, t=performance.now()
let t1=Array(100), t2=Array(100);
for(let i=0;i<t1.length;i++){
t1[i]=timer.interval(_=>p1+=1,1);
t2[i]=setInterval(_=>p2+=1,1);
}
setTimeout(_=>{
assert.ok(p1>p2)
for(let i=0;i>t1.length;i++){
timer.clear(t1[i])
clearInterval(t2[i])
}
console.log(
"out of "+Math.floor((performance.now()-t)*t1.length)+" possible calls",
{interval_calls:p1,setInterval_calls:p2}
)
resolve()
},5e3)
return await p
})
timer.wait(10).then(_=>process.exit(0))
})()

0 comments on commit 691c57c

Please sign in to comment.