microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.26k stars 29.3k forks source link

Test runners in vscode are much slower than pycharm #203003

Open dickreuter opened 9 months ago

dickreuter commented 9 months ago

Running tests in pycharm are much faster than in vscode. This poses a significant disadvantage for vscode for any serious Python project that has a large test suite.

eleanorjboyd commented 9 months ago

Hello! Would you be able to describe your use case further so we can look into the issue? If you could include an outline of your project structure (or example project which you see this behavior) and why it feels slow we can go from there. Thanks!

dickreuter commented 9 months ago

The best way to see how slow the native test explorer is, just run all pytests tests of any project. Then get the Python test explorer for Visual Studio code extension, and run all the tests with that extension. You will see that there's a speed difference of more than 2x. The native test explorer is much slower.

For example try this project and set up pytest: https://github.com/dickreuter/Poker

Any other project will experience the same. image

eleanorjboyd commented 9 months ago

By native you mean without the python extension? @connor4312, what are you thoughts here?

dickreuter commented 9 months ago

By native I mean without the Test Explorer UI, which is abandoned and recommends switching to vs code native testing. https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer

eleanorjboyd commented 9 months ago

understood- we have a few thoughts on improving performance I will investigate this further. Thanks

m-ad commented 5 months ago

I can confirm the issue: I have a Python project where running the pytest suite takes 0.2s - 0.3s in Pycharm, whereas VSCode's native Test Explorer takes between 5 and 7 seconds, that's a slowdown of more than a factor of 25. Interestingly, running the tests in a Windows terminal (not in VSCode), the tests take around 1.0s to 1.8s. That's slower than in Pycharm, but still siginificantly faster than VSCode. Don't know what kinds of optimizations Pycharm does here, but it would be a start if VSCode wouldn't be slower than the terminal.