jmwnoble;16600 wrote:Hi, I've come back to this issue because we never came up with an approach - did you have something specific in mind when you said "managing the async delays yourself so that the thread control is not transferred outside your own code" that would not require changes to the system under test, or at least changes that would not be counterproductive to going async in the first place? Thanks
I feel the best way to control this would be in your test code itself. The test code is responsible for calling into the system under test, and as such it has the ability to control the lifespan of the controlling thread. If you are working with test methods marked with 'async', the handling (and waiting) of the async blocks is pushed upward into the runner. This contrasts with having a test that controls async calls using the static Task methods, which controls the waiting on execution itself.
There may be some real hard limits to how effectively we can measure performance in a system making extensive use of async/await. Particularly when the lower level tasks responsible for a given bottleneck are being performed in library code which isn't instrumented by NCrunch. This is just the nature of async. NCrunch measures performance by examining line wall times on a held thread, which doesn't detect threads that are unwound through async's continuations. Maybe at some stage we might find a better way to handle this in NCrunch itself, but we'd need to break some big abstractions to do it... So I don't see this happening anytime soon.