Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposing the use of custom Queue implementation for message event mode #174

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding test case for irrelevant size
Signed-off-by: Thiago Santos <thiago.santos@maxmilhas.com.br>
  • Loading branch information
Thiago Santos committed Jun 25, 2020
commit d47e97871c43d1caba3d6a4e47bcdad96b6a90bc
25 changes: 25 additions & 0 deletions test/test.queue-performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,29 @@ describe('queue performance', () => {
console.log(`Queue time: ${totalQueue[0] + totalQueue[1] / 1e9}`);
expect(totalArray[0] + totalArray[1] / 1e9 > (totalQueue[0] + totalQueue[1] / 1e9) * 100).to.be.true;
});

it('the time difference between array.shift and queue.shift should be irrelevant for small lengths', () => {
const array = [];
const queue = new Queue();
for (let i = 1; i < 10000; i++) {
array.push(i);
queue.push(i);
}


const startQueue = process.hrtime();
while (queue.length > 0) {
queue.shift();
}
const totalQueue = process.hrtime(startQueue);
const startArray = process.hrtime();
while (array.length > 0) {
array.shift();
}
const totalArray = process.hrtime(startArray);

console.log(`Array time: ${totalArray[0] + totalArray[1] / 1e9}`);
console.log(`Queue time: ${totalQueue[0] + totalQueue[1] / 1e9}`);
expect(totalArray[0] + totalArray[1] / 1e9 - (totalQueue[0] + totalQueue[1] / 1e9) < 0.001).to.be.true;
});
})