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

Download leaderboard scores in parallel #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aloisklink
Copy link

Hiya, first of all, I'm loving this project, one of the coolest things I've seen!

I noticed that loading the leaderboard using the plugin is really slow on my computer (although that might just be my slow internet speeds talking).

This is because we are sequentially downloading the address and score for each player, instead of downloading them all at the same time. This will get worse as more and more people join the colossus.

This PR uses Promise.all() to download all scores at the same time, greatly speeding it up.

(By the way, you can enable the ESLint rule no-await-in-loop to check for places where you have an await in a loop, when you might be able to use Promise.all())

Hiya, first of all, I'm loving this project, one of the coolest things I've seen!

I noticed that loading the leaderboard using the plugin is really slow on my computer (although that might just be my slow internet speeds talking).

This is because we are sequentially downloading the address and score for each player, instead of downloading them all at the same time. This will get worse as more and more people join the colossus.

This PR uses [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) to download all scores at the same time, greatly speeding it up.

(By the way, you can enable the ESLint rule [`no-await-in-loop`](https://eslint.org/docs/rules/no-await-in-loop) to check for places where you have an `await` in a loop, when you might be able to use `Promise.all()`)
scotato pushed a commit that referenced this pull request Oct 4, 2021
@aloisklink
Copy link
Author

Fixed merge conflict, since console.log(`addy ${address} score ${score}`); was removed in the main branch in commit 3807d7b

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.

1 participant