-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Test collection is very slow for test class TestXYZ
#8415
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
Comments
this could be a easy win |
its using the wrong findsource, it should use inspect instead of source one |
But it seems the |
hmm, i took a glance again, i think its fair to just skip it for classes, but i wont get to try that and the rammifications this week |
#7848 (incomplete) plans to use dict ordering to solve this same problem -- just need to handle the inheritance case which I've been too busy to take another look at |
The NumPy test collection always seemed to have crept up over time, which has been bugging me a bit for a while. Right now test collection takes 1/3 or the whole execution time (for the typical test run, it was especially annoying me when running in
python3.9-dbg
where the collection-phase takes even longer).Here is the relevant part of the cProfile output (sorted by cumtime):
Digging into it, at least for NumPy that
findsource
is only used to get thelineno
ofclass TestFunction
style test-classes. If I do a silly change (this is obviously nonsense, so probably might as ):(or any other logic). EDIT: Forgot to say, this gives me about ~6x speedup of collection, I think.
The problem here is can be semi-mitigated in NumPy, or be blamed on the slow AST parser called by
inspect
. It is that we have large test files with quite manyclass TestFunction
classes, and that effectively scales quadratic, since the AST parser takes longer the more tests there are!Anyway, this might just be a duplicate of gh-2206 but I am wondering if there isn't some trivial solution, maybe the
lineno
can just be avoided since themodule.__dict__.keys()
should is probably ordered, at least on newer Python versions?The text was updated successfully, but these errors were encountered: