Improve performance of ID generation
We have noticed that the ID generation is having an heavy impact on performances of MSTest discovery/run, let's investigate what we can improve and if there are some quick wins let's do them directly.
AB#2050310
There are 2 instanced of where IDs are generated for each test, which in total take 20% of execution, plus other interactions with ObjectModel (such as adding traits to traits collection).
I am not sure where the bottleneck of the id generation is, but it does ask reflection for information that we already have (e.g. information about assembly), and that we could pass in. It also does not seem to handle strings in an efficient way.
All the hotspots here are easy to measure by running a test project under PerfView and specifying --list-tests. See the changes here to add stopwatch around the discovery to not take writing to console into account.
https://github.com/nohwnd/testfx/tree/discovery-optimize-and-break
@Evangelink can u point me to the code that does the id generation?
@nohwnd I created the ticket from your feedback but didn't look at it. From the branch you have linked, I see mainly changes to reflection helpers nothing around ID generation. Can you answer @SimonCropp here?
Managed name and getting test id were the places where I saw it.
https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs#L74
https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs#L294
https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs#L334
https://github.com/microsoft/vstest/tree/main/src/Microsoft.TestPlatform.AdapterUtilities The source code is here.