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

Overhead per test function call too large. #32

Closed
pytestbot opened this issue Mar 7, 2011 · 6 comments
Closed

Overhead per test function call too large. #32

pytestbot opened this issue Mar 7, 2011 · 6 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko)


pytest seems to have large overhead per test function call.

To demonstrate the effect try running the attached test script with its 'all_in_one' parameter set to:

  • True - to do all its work in a single test function call
  • False - to split its work over multiple test function calls

In my test run I got the following times with 1000 assertions:

  • all_in_one = True ... 0.03 seconds.

  • all_in_one = False ... 5.44 seconds.

    Hope this helps.

    Best regards,
    Jurko Gospodnetić


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


If you install (via -i http://pypi.testrun.org as usual) pytest-2.0.2.dev7 you get a little speedup. Can you verify how much on your machine?

Oh, and if you run with "py.test --capture=sys" (simple capturing instead of fd-level capturing) or with no capturing "py.test -s" you may get some additional speedup.

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


Just tried running:
{{{
easy_install -i http://pypi.testrun.org pytest
}}}
but that did not find the dev7 version you mention.

{{{
C:\Documents and Settings\Jurko\aaa>easy_install -i http://pypi.testrun.org pytest
install_dir C:\Program Files\Python\Python32\Lib\site-packages
Searching for pytest
Best match: pytest 2.0.2.dev6
Processing pytest-2.0.2.dev6-py3.2.egg
pytest 2.0.2.dev6 is already the active version in easy-install.pth
Installing py.test-script.py script to C:\Program Files\Python\Python32\Scripts
Installing py.test.exe script to C:\Program Files\Python\Python32\Scripts
Installing py.test-3.2-script.py script to C:\Program Files\Python\Python32\Scripts
Installing py.test-3.2.exe script to C:\Program Files\Python\Python32\Scripts

Using c:\program files\python\python32\lib\site-packages\pytest-2.0.2.dev6-py3.2.egg
Processing dependencies for pytest
Finished processing dependencies for pytest
}}}

I did however manage to get a newer pylib dev8 version - not sure if that will help.

Best regards,
Jurko Gospodnetić

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


Just tested the 'py.test --capture=sys' command and it does seem to cut down the overhead to about 50%. Still not the 0.03 seconds for running everything as a single py.test test function call :-) but getting there...

  • With regular fd-level capturing: 5.42 seconds.
  • With 'sys' capturing: 2.73 seconds.

Seems like the 'sys' capturing should be the default. :-)

What exactly are the effects or one or the other type of capturing? More detailed failure reporting in case of fd-level capturing? If so, then that seems like something that should be enabled explicitly only when needed...

Best regards,
Jurko Gospodnetić

@pytestbot
Copy link
Contributor Author

Original comment by Anonymous:


You need the -U switch to force an upgrade maybe.

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


Yup, that was it. Hmmm, sorry, not really at home with easy-install... was expecting it to upgrade to the latest version by default.

The new pytest-2.0.2.dev7 version produced the following timings on my system:

* With regular fd-level capturing: 3.97 seconds (26,75% speedup).
* With 'sys' capturing: 1.45 seconds (46,89% speedup).

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


i presume it's fast enough for now :)

fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
bluetech referenced this issue in bluetech/pytest Aug 24, 2020
Traced it's addition to an optimization as part of issue #32. The
speedup was meant for a many-tests-in-a-file benchmark. For each test,
`rootdir.bestrelpath(fspath of test)` is called, and the cache is of
this slow `bestrelpath`.

TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

1 participant