-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Performant queue #51
base: master
Are you sure you want to change the base?
Performant queue #51
Conversation
return this; | ||
} | ||
|
||
shift() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to use enqueue/dequeue methods and under the hood add elements with array.unshift, and remove elements with offset/slice. Need to check performance and compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach was to match current array methods (push/shift) to minimize refactoring, but I agree that enqueue/dequeue could be more convinient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here is test/queue-performance.js
performance comparison test to compare queues of 100k elements. It shows ~25x execution time difference. This factor is growing with queue size e.g. ~800x at 500k elements.
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Implement and introduce queue mentioned in #50
npm t
)npm run fmt
)