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

throttle-promises expectedHistory seems to be wrong #41

Closed
chemzqm opened this issue Oct 22, 2015 · 1 comment
Closed

throttle-promises expectedHistory seems to be wrong #41

chemzqm opened this issue Oct 22, 2015 · 1 comment

Comments

@chemzqm
Copy link

chemzqm commented Oct 22, 2015

The expectedHistory is

0,1,2,3,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,3,2,1,0

but it should be

0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0

Comparing with this https://github.com/kolodny/exercises/blob/master/throttle-promises/test.js#L36 variable also makes the process stop responsing, don't know the reason

@jcready
Copy link

jcready commented Nov 1, 2015

The expected history is correct the way it is. What you listed as your expected history would mean that 5 promises get executed and another 5 won't start until those original 5 have all resolved (which isn't correct). What should happen (and what is correctly being tested already) is that 5 promises get executed right away and as soon as any one of them resolves, another one gets started.

While your solution might only execute a 5 promises at a time (which is correct), it is much less efficient than it could be. Your solution is averaging ~2.5 running promises at any given time while the optimal solution (and what is already being tested) is averaging ~4.5 running promises.

@kolodny kolodny closed this as completed Nov 8, 2015
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

No branches or pull requests

3 participants