#!/usr/bin/env bash # Unoffical Bash "strict mode" # http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail #ORIGINAL_IFS=$IFS IFS=$'\t\n' # Stricter IFS settings # Data dir data_dir=${1:-} # Output dir output_dir=${2:-} generate_combined_csv_for_command() { local command_name command_name=${1:-} # Print CSV header echo "version,command,mean,stddev,median,user,system,min,max" # Combine multiple CSVs ls "$data_dir/"*"$command_name".csv | sort -V | for file in $(cat /dev/stdin); do # Print the version from the filename echo -n "$(basename "$file")" | cut -f1 -d_ | tr '\n' ' ' # get all but the first row of the CSV (header) from the file benchmark_data="$(tail -n 1 < "$file")"; # Check if we have benchmark data for this command, we may not if the # command wasn't able in this version of asdf if [ -z "$benchmark_data" ]; then # if empty print an entire empty row echo ",,,,,,,," else # Print comma following the version echo -n "," # print all but the first row of the CSV (header) from the file echo -n "$benchmark_data" fi # Print a trailing newline echo; done | sed -e '/^$/d' } # Generate a combined file for each command we've benchmarked generate_combined_csv_for_command "asdf-current" > "$output_dir"/asdf-current.csv generate_combined_csv_for_command "asdf-exec-lua--v" > "$output_dir"/asdf-exec.csv generate_combined_csv_for_command "asdf-reshim" > "$output_dir"/asdf-reshim.csv generate_combined_csv_for_command "asdf-where-lua" > "$output_dir"/asdf-where.csv generate_combined_csv_for_command "asdf-which-lua" > "$output_dir"/asdf-which.csv