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

Speed up builds by using multiple cores and parallel building #41

Open
CodingMarkus opened this issue Dec 30, 2021 · 1 comment
Open

Comments

@CodingMarkus
Copy link

Just add this at the very top of your script:

# Detect how many CPU cores are available
cores=$( (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1 )

This command will detect the number of CPU cores available on either Linux (nproc) or BSD-like systems (sysctl), including FreeBSD and macOS, and just fall back to 1 on all other systems, which is the same behavior the script currently has, where only one core is used.

And then replace every make with make -j "$cores" and the entire script runs almost 4 times faster on my system.

@chrissimpkins
Copy link
Member

Thanks! Interested in submitting a pull request to add this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants