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

Avoid more overhead of assembly initialize #4349

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented Dec 13, 2024

Looks like we are spending about 1% of the test run on 1k tests trying to setup assembly initialize contexts inside of RunAssemblyInitializeIfNeeded, only to enter the child method that would run AssemblyInitialize where we just return if we already run the code.

Comment on lines +165 to +170
if (!testMethodInfo.Parent.Parent.IsAssemblyInitializeExecuted)
{
assemblyInitializeResult = RunAssemblyInitializeIfNeeded(testMethodInfo, testContext);
}

if (assemblyInitializeResult != null && assemblyInitializeResult.Outcome != UnitTestOutcome.Passed)
Copy link
Member

Choose a reason for hiding this comment

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

This changes the semantics of the code I think.

Previously, if assembly initialize failed, we will attach the failure for every single test run. While now, it's only attached for the first test.

Copy link
Member Author

Choose a reason for hiding this comment

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

from the code it looks like we prepare to capture outputs of the initialize method in every single test, but we actually run zero times or one time. so hopefully this changes nothing. We just prevent setting up capturing of output for method that will immediately return.

@nohwnd nohwnd marked this pull request as draft December 13, 2024 16:42
@nohwnd
Copy link
Member Author

nohwnd commented Dec 13, 2024

Not sure why that test complains, but running against local build produces error for every test. So probably the acceptance test is wrong:
image

@nohwnd
Copy link
Member Author

nohwnd commented Dec 13, 2024

same for class init:
image

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.

2 participants