Skip to content

NUnit with dotnet test results in O(n^2) filtering complexity #3786

Closed
@pakrym

Description

@pakrym

The usual pattern for dotnet test when invoking test is to pass an Or filter with a FullNameFilter for every test it wants to run.

To check if the Or filter matches the test we need to iterate over every child filter and do it for every test in the project that results in O(n^2) time complexity. It's not noticeable on small projects but is very noticeable on large ones (9000+ tests).

One solution is to reduce the OrFilter that only has FullNameFilter to a HashSet-based filter that would reduce overall complexity to O(N). I prototyped it in #3787

For real-world data, the https://github.com/azure/azure-sdk-for-net/blob/1814567d1f6cfb4905539e71d54377ab46ed6737/sdk/storage/Azure.Storage.Blobs takes 80 sec to run but only 40 with the fix from the #3787.

Considering tests themselves take ~ 25-30 sec to run it's a 5X filter time improvement.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions