-
Notifications
You must be signed in to change notification settings - Fork 758
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
Test method EventSource for easier diagnostics #2484
Comments
Sure, that would be great! |
@adamsitnik want this :) |
The event source is now available in pre-release builds. Available in v2 @adamsitnik has an open PR for documentation that needs to be iterated on, because in particular, Concurrency Visualizer has strict requirements regarding threads that xUnit.net cannot comply with. So when using CV and visualizing your tests, you may run into situations where you see start & stop events that are "disconnected" from one another by virtue of being on different threads. Purely synchronous tests should not have issues here, and in theory tests which use only As an example, here is some timing from running Most of the tests are successfully correlated start/stop, but some still show up as red diamonds and mismatched pairs of start/stop, which you could track down by hand if needed. (You'll probably need to click through the image to see any level of detail.) |
I'm going to leave this issue open until we have the docs finalized and deployed. |
It's probably also worth pointing out that any test which is async will have "questionable" timing, since any time |
Alternatively, if you're just looking for a way to find long-running tests, you can enable long running test detection support. Combining this with disabling parallelization (and only running a single test project on an otherwise idle machine) will help to give very accurate timing of individual tests, even though the full test run may take significantly longer as a result. |
Hello everyone!
I was recently wondering how I could reduce the time it takes to run all dotnet/runtime unit tests. I've done some profiling and realized, that for many CPU-bound unit tests projects we are not even close to using 50% of all the CPU cores. Example: System.Linq.Tests use 15% of all my 24 cores.
The best way to visualize such information is by using dedicated tools like Concurrency Visualizer or Chromium Developer Tools.
But these tools need some extra information, which can be emitted by using EventSource (part of .NET Standard 1.1).
So I've forked xUnit and extended it with custom
EventSource
and the logic that simply logs start and stop events for every test invocation. The code itself is very simple:I've configured VS Concurrency Visualizer to log these events (every event is disabled by default):
And profiled the test project.
The Concurrency Visualizer recognizes Start & Stop events and displays them nicely in the
Threads
view. In the following example I was able to quickly identify few unit tests that run alone when all other tests have already finished:@bradwilson would you be interested in me adding such
EventSource
to xUnit? I could provide implementation for all versions and documentation with examples.EventSource
is part of .NET Standard 1.1 and logging is disabled by default, so there is no perf penalty for users who don't use it. Start & Stop events are recognized by other profilers and diagnostics software.The text was updated successfully, but these errors were encountered: