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

Rewrite EmptyDefaultValueProvider to use dictionary lookup for special type handling #524

Merged
merged 2 commits into from
Nov 19, 2017

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Nov 19, 2017

This is a lot more efficient (I observed speed-ups of simple mock method invocations by 67%) and makes it possible to easily add handling of additional types that are currently ignored (such as List<T>, IReadOnlyList<T>, etc.).


var setResultMethod = tcs.GetType().GetMethod("SetResult");
var taskProperty = tcs.GetType().GetProperty("Task");
private static object CreateTaskOf(Type type)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly enough, while creating a completed task via Task.FromResult<T> is about 16x as fast as via TaskCompletionSource<T>, the same is not true if done via reflection: Task.FromResult<T> then becomes a little slower even though less reflection calls are involved. So we don't change over to a Task.FromResult-based solution.

@stakx stakx merged commit f8475f6 into devlooped:develop Nov 19, 2017
@stakx stakx deleted the emptydefaultvalueprovider branch November 19, 2017 15:33
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

1 participant