Created
November 21, 2024 01:06
-
-
Save robzolkos/cfebd0b65d12e33aad2f3a0062657661 to your computer and use it in GitHub Desktop.
See Rails parallel test speed with various cores
This file contains 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
#!/bin/bash | |
# Get the number of CPU cores available | |
num_cores=$(nproc) | |
# Set the test seed to ensure the tests are deterministic | |
seed=$(ruby -e 'puts Random.new_seed') | |
# Create a temporary file to store the results | |
output_file="test_times.txt" | |
# Print table headers | |
echo -e "Cores\tTime (seconds)" > $output_file | |
# Loop through core counts from 1 to the number of cores | |
for (( cores=1; cores<=$num_cores; cores++ )) | |
do | |
echo "Running tests with $cores core(s)..." | |
# Run the tests with the specified number of cores and capture the time | |
start_time=$(date +%s) | |
PARALLEL_WORKERS=$cores SEED=$seed rails test | |
end_time=$(date +%s) | |
elapsed_time=$((end_time - start_time)) | |
# Output the result in the table format | |
echo -e "$cores\t$elapsed_time" >> $output_file | |
done | |
# Display the results | |
echo "Test results saved to $output_file" | |
cat $output_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment