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

Optimize SetupCollection (esp. ToArrayLive) for better performance #819

Merged
merged 3 commits into from
Apr 27, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Apr 27, 2019

SetupCollection.ToArrayLive is a fairly expensive operation and gets called more often (esp. during verification) now that inner mocks are represented as regular setups. This applies some optimizations that can easily double the speed of that operation (or more!), esp. when any overridden setups are present.

Explicitly partitioning setups by `MethodInfo` is not necessary since
`InvocationShape.GetHashCode` in essence already does this, so we can
just use a `HashSet<..>` instead of a `Dictionary<MethodInfo, ..>`.
...using simple bit mask checks. This helps avoid much more expensive
operations such as comparing expression trees. This optimization only
applies to the first 32 setups as that will be sufficient in many real
world scenarios and means we don't need a (more complicated) variable-
sized bit vector.
@stakx stakx merged commit 5d65d46 into devlooped:master Apr 27, 2019
@stakx stakx deleted the setupcollection branch April 27, 2019 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant