-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
dotnet test discovery slow #517
Comments
Looks like the lookup function at expecto/Expecto/Expecto.Impl.fs Line 989 in 6931d33
will reread the module definition with Cecil for each test case, which might be duplicating a lot of work if there are many tests? If that's the case, maybe it'd be possible to cache the data, or maybe have a function to get the source location for multiple test cases at once to reduce the overhead? |
I've only superficially interacted with the code location so far. Reading through it, I think @Numpsy identified a good candidate. The Profiling the code would probably be a good next step. |
That certainly looks like caching module types could make a significant difference. |
let private moduleDefinitionCache = new ConcurrentDictionary<string, Map<string,TypeDefinition>>()
let getTypesForAssemblyLocation (asm: Assembly) =
moduleDefinitionCache.GetOrAdd(asm.Location, valueFactory=(fun loc ->
let readerParams = ReaderParameters( ReadSymbols = true )
let moduleDefinition = ModuleDefinition.ReadModule(loc, readerParams)
seq { for t in moduleDefinition.GetTypes() -> (t.FullName, t) }
|> Map.ofSeq
)) Something like this would probably be good enough |
👋 So I've been annoyed by a specific problem for a while. When running Expecto under
dotnet test
it seems to take ages to find the tests. This gets really bad for very large test suites. I finally discovered what was happening (yes I know this begins in YoloDev but please bear with me).YoloDev's test discovery eventually calls
getLocation
for every test which is in Expecto itself:expecto/Expecto/Expecto.Impl.fs
Line 1020 in 6931d33
This is some pretty complicated code trying to find the location of a test. Expecto seems to never actually use this, so it's not affected in
dotnet run
scenarios.At this point I don't really have a suggestion, but I wanted to at least bring it up and document it so other people can see the problem and maybe have a discussion about how to do this better.
Related:
ionide/FsAutoComplete#1334
The text was updated successfully, but these errors were encountered: