playwright: [BUG]: Playwright execution performance - high CPU usage

Context:

  • Playwright Version: 1.28.0
  • Operating System: Mac OS Monterey (Apple M1, 16GB)
  • Python: 3.9.6
  • Browsers: All (Chromium, Firefox, WebKit)
  • Extra:
  1. pytest-xdist==1.29.0 for running tests
  2. pytest fixures are used @pytest.fixture(scope="function") -> on the scope level browser context and page are created and the page is used through test, at the end of scope(in this case at the end of test) the context and the browser are closed (also tried with scope=“session” but had too many problems in the case when I have many scenarios(>50))

Describe the bug

The problem is high CPU usage while tests running on my local machine (details described above). If I have for example 2 tests and run them with 2 workers, CPU usage becomes high (up to 50-70%) at some moment which is very high and unacceptable if we take into account that execution times are not too long and also these tests are some of the simpler ones I have.

Source code

https://github.com/TestTheTest7/pw_project

Some facts:

  • the same behaviour for any number of workers (>1)
  • the same behaviour for all browser types
  • please see CPU usage Screenshot 2023-03-09 at 15 32 54 png 2023-03-09 15-33-50

Notes:

  • this project is a prototype of a big project, some things in this project don’t make sense e.g. here I have some methods that override playwright’s methods cause in the original project they are extended and they contain other things
  • here I have two tests (playwright_test_1.py and playwright_test_2.py) with the same steps for CPU testing purposes
  • these tests are some of the simpler ones I have in the original project

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

ksnip_20231226-171413 ksnip_20231226-171353 Every start of playwright tests causes 100% CPU load. Is it fault of some media on target site or something else?