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

Jest with SWC doesn't seem much faster than Jest with babel :( #1172

Closed
benwainwright opened this issue Oct 16, 2020 · 4 comments
Closed

Jest with SWC doesn't seem much faster than Jest with babel :( #1172

benwainwright opened this issue Oct 16, 2020 · 4 comments

Comments

@benwainwright
Copy link

benwainwright commented Oct 16, 2020

So I've spent today experimenting with swapping out tsc for swc in our small typescript project (ejected create-react-app typescript/react), and if I'm honest I've been... a bit disappointed.

The project is moderately small so test times are not a huge deal yet, but anticipating it getting bigger, I was looking for an improvement on testing times, but after benchmarking (using yarn add jest-benchmark) test runs with swc-jest and the default babel config that comes with create react app, the speed seemed to be about the same.

Here is the results of the benchmarking our jest tests with swc:

image

And here is the same thing using our normal jest config:

image

As you can see; the improvement in the whole test run is about 0.25 seconds per run - nothing to write home about and certainly not worth swapping out a tried and tested part of our toolchain for. Now I appreciate that babel is likely not the only bottleneck in a jest run, but given all the impressive claims I've seen in various places about swc, is this really what I'd expect to see? Or have I configured something wrong. Swapping babel-loader out for swc-loader doesn't seem like a massive improvement in terms of build times either, though I've not yet found an easy way of benchmarking that. Below are the configs that I used to get swc working:

jestConfig transform block in package.json

image

.swcrc

image

@kdy1
Copy link
Member

kdy1 commented Oct 16, 2020

swc cannot optimize the time used for running test. It just reduces time of transpiling.

@kdy1 kdy1 closed this as completed Oct 16, 2020
@benwainwright
Copy link
Author

@kdy1 That's a complete non answer to my question (if you actually read what I wrote, you'll see that I more or less accept that), so I'll restate it in the hope that someone will actually answer me:

Now I appreciate that babel is likely not the only bottleneck in a jest run, but given all the impressive claims I've seen in various places about swc, is this really what I'd expect to see? Or have I configured something wrong.

@kitsonk
Copy link
Contributor

kitsonk commented Oct 16, 2020

For testing, especially benchmarks, transpiling code is likely less than 1% of the time spent on the test, so optimising 1% of a process will lead to the results you are seeing. I don't know the internals of jest, but I suspect it doesn't even transpile on every run, so you are only get a one off improvement in startup.

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 26, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants