Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

perf: use decrement instead of splice/indexOf #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bengl
Copy link

@bengl bengl commented Mar 29, 2016

In _onAll, individual elements were being removed from an array to track
if they had been run. In reality, all that's needed is to know when
all of them have been run. This can be acheived by simply getting
the original array length, and decrementing it upon completion of an
element, with a stop condition when the count is zero.

In a small benchmark, this increased speeds for resolution of a graph by
roughly 4.5x
. This was clearly the lowest hanging fruit in terms of
performance of asyncgrpah.

In _onAll, individual elements were being removed from an array to track
if they had been run. In reality, all that's needed is to know when
*all* of them have been run. This can be acheived by simply getting
the original array length, and decrementing it upon completion of an
element, with a stop condition when the count is zero.

In a small benchmark, this increased speeds for resolution of a graph by
roughly 4.5x. This was clearly the lowest hanging fruit in terms of
performance of asyncgrpah.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant