Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Eliminate unnecessary async operations when parsing JSON #61

Closed
ChengTian opened this issue Sep 10, 2014 · 0 comments
Closed

Eliminate unnecessary async operations when parsing JSON #61

ChengTian opened this issue Sep 10, 2014 · 0 comments
Assignees
Milestone

Comments

@ChengTian
Copy link
Contributor

Suggestion from @PinpointTownes regarding the change at 13adde6#commitcomment-7735513

My 2 cents: these Task -returning methods have been removed for a reason: they were not really asynchronous and used Task.Factory.StartNew / Task.Run internally. Offloading pure CPU-bound operations to the thread pool is generally not a good idea and often incur a little overhead, and that's why this kind of practices should be limited to UI, where responsiveness is essential. Don't miss this topic if you want more information: JamesNK/Newtonsoft.Json#66

Even if these methods are only used in unit tests, I'd suggest removing Task.Factory.StartNew and making ReturnJsonResponse synchronous (or using Task.FromResult if you wanna keep it async) to reduce the cost of thread switching and limit its impact on the execution duration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants