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

Performant queue #51

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Performant queue #51

wants to merge 15 commits into from

Conversation

JaoodxD
Copy link

@JaoodxD JaoodxD commented Mar 14, 2023

Implement and introduce queue mentioned in #50

  • tests and linter show no problems (npm t)
  • tests are added/updated for bug fixes and new features
  • code is properly formatted (npm run fmt)
  • description of changes is added in CHANGELOG.md
  • update .d.ts typings

web-locks.js Outdated Show resolved Hide resolved
return this;
}

shift() {
Copy link
Member

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

Copy link
Author

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.

Copy link
Author

@JaoodxD JaoodxD Mar 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants