Skip to content

Commit

Permalink
Fixed time_test[after]
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyal-Shalev committed May 17, 2022
1 parent 18e1651 commit fa465a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ jobs:
files: |
LICENSE
README.md
dist/*.iife.js
dist/*.iife.min.js
dist/async_channels.iife.js
dist/async_channels.iife.min.js
- uses: marvinpinto/action-automatic-releases@latest
if: ${{ ! needs.version.outputs.is_pre }}
Expand All @@ -202,5 +202,5 @@ jobs:
files: |
LICENSE
README.md
dist/*.iife.js
dist/*.iife.min.js
dist/async_channels.iife.js
dist/async_channels.iife.min.js
21 changes: 12 additions & 9 deletions src/time_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ Deno.test("Timer -> stop -> reset", async () => {
});

Deno.test("after", async () => {
const duration = 50;
const start = new Date();
const [end] = await after(duration).get();
assert(end !== undefined, "channel should be open");
assertNumberBetween(
end.getTime() - start.getTime(),
duration,
duration + 10,
);
const intervals = [];
const duration = 10;
for (const _ of Array(100)) {
const start = new Date();
const [end] = await after(duration).get();
assert(end !== undefined, "channel should be open");
intervals.push((end.getTime() - start.getTime()) - duration);
}
intervals.sort();
const p95 = intervals[Math.floor(intervals.length * 0.95)];
console.log(p95, intervals);
assertLessThan(p95, 10);
});

async function analyzeTicker(interval: number, times: number) {
Expand Down

0 comments on commit fa465a4

Please sign in to comment.