magyarsort/results/2025/combinator.inc
2025-10-04 06:30:11 +02:00

69 lines
1.7 KiB
PHP

# Just . combinator.inc or source combinator.inc
# After that,
echo "You can (manually):"
echo "- header data.csv"
echo "- fill data.csv magyar rand"
echo "Or create comparison for a specific data kind:"
echo "- genfor rand data.csv"
echo "Or just a big default mess:"
echo "- generate data.csv"
echo "To cleanup data for libreoffice calc (hungarian one that is):"
echo "- cleanup data.csv"
echo ""
echo "The generate gives a 'default set' that you can add your missing stuff with further 'fill' commands if needed"
basefile=5000000.txt
declare -a definputs=("worst" "smallrange" "rand" "constant")
declare -a sortalgs=(`awk '/worst/{getline; last=1} last{for(x=1;x<=NF;++x) print $x}' ORS=' ' $basefile`)
# header data.csv
header() {
outfile="$1"
echo -n 'alg ' > "$outfile"
awk 'BEGINFILE{n=""} {if(n =="") n = $2} ENDFILE{print n}' ORS='\t' `ls -tr --time=birth *.txt` | sed 's/,$//' >> "$outfile"
echo "" >> "$outfile"
}
# fill data.csv magyar rand
fill() {
outfile="$1"
alg="$2"
input="$3"
col=$(cat $basefile | grep copy | sed 's/^\s*//' | awk "{out[NR] = \$1} END {for(i=1;i<=NR;i++) if(out[i] == \"$alg\") print i;}" RS=' +')
echo -n "$alg-$input " >> "$outfile"
awk "/$input/{print \$($col+1)}" ORS='\t' `ls -tr --time=birth *.txt` >> "$outfile"
echo "" >> "$outfile"
}
# genfor "rand" data.csv
genfor() {
inp="$1"
outfile="$2"
header "$outfile"
for alg in "${sortalgs[@]}"; do
echo -n "Adding $alg-"; echo "$inp"
fill "$outfile" "$alg" "$inp"
done
}
# generate data.csv
generate() {
outfile="$1"
header "$outfile"
for inp in "${definputs[@]}"; do
genfor "$inp" "$outfile"
done
}
# cleanup data.csv prepared.csv
cleanup() {
in="$1"
out="$2"
sed "s/\([0-9][0-9]*\)\.\([0-9][0-9]*\)s/\1,\2/g" "$in" > "$out"
}