Created
March 10, 2026 09:14
-
-
Save Awlexus/1f7f2f51d27eef40f82f04c0ebde7444 to your computer and use it in GitHub Desktop.
A simple script for evaluating compilation performance of an elixir project across multiple elixir versions. Requires mise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| ROOT_DIR="$(pwd)" | |
| ELIXIR_VERSIONS=( | |
| "1.18.4-otp-28" | |
| "1.19.3-otp-28" | |
| "1.19.5-otp-28" | |
| "1.20.0-rc.1-otp-28" | |
| "1.20.0-rc.2-otp-28" | |
| "1.20.0-rc.3-otp-28" | |
| ) | |
| PARTITION_COUNTS=(1 2 4) | |
| ERLANG_VERSION="28.3" | |
| if [[ ! -d "${ROOT_DIR}/deps" || -z "$(ls -A "${ROOT_DIR}/deps" 2>/dev/null)" ]]; then | |
| echo "deps directory is empty. Run 'mix deps.get' before profiling." >&2 | |
| exit 1 | |
| fi | |
| printf "%-20s %-18s %-8s %-12s %s\n" \ | |
| "timestamp" \ | |
| "elixir_version" \ | |
| "stage" \ | |
| "partition" \ | |
| "seconds" | |
| printf "%-20s %-18s %-8s %-12s %s\n" \ | |
| "--------------------" \ | |
| "------------------" \ | |
| "--------" \ | |
| "------------" \ | |
| "-------" | |
| run_timed() { | |
| local version="$1" | |
| local stage="$2" | |
| local partition="$3" | |
| shift 3 | |
| local time_file | |
| local err_file | |
| time_file="$(mktemp)" | |
| err_file="$(mktemp)" | |
| /usr/bin/time -p -o "${time_file}" env LC_ALL=C "$@" > /dev/null 2> "${err_file}" || { | |
| cat "${err_file}" >&2 | |
| rm -f "${time_file}" "${err_file}" | |
| exit 1 | |
| } | |
| local real_time | |
| real_time="$(awk '/^real /{print $2}' "${time_file}" | tr ',' '.')" | |
| rm -f "${time_file}" "${err_file}" | |
| printf "%-20s %-18s %-8s %-12s %s\n" \ | |
| "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ | |
| "${version}" \ | |
| "${stage}" \ | |
| "${partition}" \ | |
| "${real_time}" | |
| } | |
| for version in "${ELIXIR_VERSIONS[@]}"; do | |
| if [[ "${version}" == "1.18.4-otp-28" ]]; then | |
| run_timed \ | |
| "${version}" \ | |
| "deps" \ | |
| "unset" \ | |
| mise exec "elixir@${version}" "erlang@${ERLANG_VERSION}" -- \ | |
| env -u MIX_OS_DEPS_COMPILE_PARTITION_COUNT MIX_ENV=dev \ | |
| mix deps.compile --force | |
| else | |
| for partition in "${PARTITION_COUNTS[@]}"; do | |
| if [[ "${partition}" == "1" ]]; then | |
| run_timed \ | |
| "${version}" \ | |
| "deps" \ | |
| "unset" \ | |
| mise exec "elixir@${version}" "erlang@${ERLANG_VERSION}" -- \ | |
| env -u MIX_OS_DEPS_COMPILE_PARTITION_COUNT MIX_ENV=dev \ | |
| mix deps.compile --force | |
| else | |
| run_timed \ | |
| "${version}" \ | |
| "deps" \ | |
| "${partition}" \ | |
| mise exec "elixir@${version}" "erlang@${ERLANG_VERSION}" -- \ | |
| env MIX_ENV=dev MIX_OS_DEPS_COMPILE_PARTITION_COUNT="${partition}" \ | |
| mix deps.compile --force | |
| fi | |
| done | |
| fi | |
| run_timed \ | |
| "${version}" \ | |
| "project" \ | |
| "default" \ | |
| env MIX_ENV=dev \ | |
| mise exec "elixir@${version}" "erlang@${ERLANG_VERSION}" -- \ | |
| mix compile --force | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment