Skip to content

Instantly share code, notes, and snippets.

@inopinatus
Last active July 17, 2019 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inopinatus/9c6f98e2e9aa43b0f86eef4ad6b14401 to your computer and use it in GitHub Desktop.
Save inopinatus/9c6f98e2e9aa43b0f86eef4ad6b14401 to your computer and use it in GitHub Desktop.
crude little benchmark for parallelizing bundle-installed gems
#!/bin/bash
TMPDIR="$(mktemp -d)"
CORES=$(sysctl -n hw.ncpu 2>/dev/null || nproc)
echo "==> testing with $CORES cores in $TMPDIR"
cd $TMPDIR
RUBY_VERSION=$(rbenv version-name)
TIME=$(which time)
function run {
export MAKEFLAGS="-j$1"
export BUNDLE_JOBS="$2"
export GEMSET="gems_${RUBY_VERSION}_make${MAKEFLAGS}_bundle-jobs-${BUNDLE_JOBS}"
echo "==> installing Rails for $GEMSET"
echo "./${GEMSET} global" >.ruby-gemset
$TIME ruby -r bundler/inline -e 'gemfile { source "https://rubygems.org"; gem "rails", "6.0.0.rc1" }'
}
run 1 1
run 1 $CORES
run $CORES 1
run $CORES $CORES
echo '==> cleaning up'
rm -rf "$TMPDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment