ollama-test, add colors and mention which context and thread count the winners were at.

This commit is contained in:
me committed 2026-10-24 21:35:17 -07:00
1 parent ccdc7ea5ed
commit ffbf55c1ed
1 file changed
+46 -27
+46 -27
View File
@@ -1665,7 +1665,7 @@ function ollama_benchmark() {
log_file="ollama_benchmark.log.txt"
[[ -z "$QUIET" ]] && echo -e "\n Logging ollama to '$log_file'..."
declare champ_{speed,time}_{model,num}
declare champ_{s,t}_{mdl,num,ctx,thr}
# Functions
@@ -1687,25 +1687,40 @@ function ollama_benchmark() {
[[ -z "$QUIET" ]] && echo -e "\n Starting main loop... \n"
printf "| %-${col_mdl}s | %${col_hdd}s | %${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}s | %${col_tim}s |\n" \
declare GRY="`tput setaf 8`" WHT="`tput setaf 7`" RST="`tput sgr0`"
printf "$WHT| %-${col_mdl}s | %${col_hdd}s | %${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}s | %${col_tim}s |\n" \
"Model" "HDD" "Context" "RAM" "Threads" "iGPU" "Processor" "Speed (t/s)" "Time (s)"
printf "| %-${col_mdl}s | %${col_hdd}s | %${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}s | %${col_tim}s |\n" \
printf "| %-${col_mdl}s | %${col_hdd}s | %${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}s | %${col_tim}s |$RST\n" \
":------------------------" "-----:" "-------:" "-----:" "------:" "---:" "--------:" "----------:" "-------:"
last_igpu=""
count=0
for model in $models; do
for context in $contexts; do
for thread in $threads; do
for igpu in $igpus; do
(killall ollama >/dev/null 2>&1)
sleep 5
export OLLAMA_IGPU_ENABLE=$igpu
export OLLAMA_VULKAN=$igpu
(ollama serve >$log_file 2>&1 &)
wait_for_ollama
if [[ -z "$last_igpu" || "$last_igpu" != "$igpu" ]]; then
killall ollama >/dev/null 2>&1
sleep 5
export OLLAMA_IGPU_ENABLE=$igpu
export OLLAMA_VULKAN=$igpu
(ollama serve >$log_file 2>&1 &)
wait_for_ollama
sleep 5
fi
last_igpu="$igpu"
declare CLR="$WHT"
if (( count % 2 == 1 )); then
CLR="$GRY"
fi
(( count++ ))
hdd="`ollama ls | grep $model | awk '{print $3 $4}'`"
printf "| %-${col_mdl}s | %${col_hdd}s | " "$model" "$hdd"
printf "$CLR| %-${col_mdl}s | %${col_hdd}s | " "$model" "$hdd"
# Start the model and store the response.
start=$SECONDS
@@ -1754,26 +1769,30 @@ function ollama_benchmark() {
cpu="`ollama ps | grep $model | awk '{print $5 $6}'`"
ctx="`ollama ps | grep $model | awk '{print $7}'`"
[[ -n "$DEBUG" ]] && echo "DEBUG: champ_speed_num=$champ_speed_num, speed=$speed"
if [[ -z "$champ_speed_num" ]] \
|| awk -v a="$speed" -v b="$champ_speed_num" 'BEGIN { exit !(a > b) }'
[[ -n "$DEBUG" ]] && echo "DEBUG: champ_s_num=$champ_s_num, speed=$speed"
if [[ -z "$champ_s_num" ]] \
|| awk -v a="$speed" -v b="$champ_s_num" 'BEGIN { exit !(a > b) }'
then
[[ -n "$DEBUG" ]] && echo "DEBUG: New speed champ!"
champ_speed_num="$speed"
champ_speed_model="$model"
champ_s_num="$speed"
champ_s_mdl="$model"
champ_s_ctx="$ctx"
champ_s_thr="$thr"
fi
[[ -n "$DEBUG" ]] && echo "DEBUG: champ_time_num=$champ_time_num, time=$time"
if [[ -z "$champ_time_num" ]] \
|| awk -v a="$time" -v b="$champ_time_num" 'BEGIN { exit !(a < b) }'
[[ -n "$DEBUG" ]] && echo "DEBUG: champ_t_num=$champ_t_num, time=$time"
if [[ -z "$champ_t_num" ]] \
|| awk -v a="$time" -v b="$champ_t_num" 'BEGIN { exit !(a < b) }'
then
[[ -n "$DEBUG" ]] && echo "DEBUG: New time champ!"
champ_time_num="$time"
champ_time_model="$model"
champ_t_num="$time"
champ_t_mdl="$model"
champ_t_ctx="$ctx"
champ_t_thr="$thr"
fi
fi
printf "%${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}.${col_spd_round}f | %${col_tim}s |\n" \
printf "%${col_ctx}s | %${col_ram}s | %${col_thr}s | %${col_gpu}s | %${col_cpu}s | %${col_spd}.${col_spd_round}f | %${col_tim}s |$RST\n" \
"$ctx" "$ram" "$thread" "$igpu" "$cpu" "$speed" "$time"
ollama stop $model >/dev/null 2>&1
@@ -1786,10 +1805,10 @@ function ollama_benchmark() {
done
done
[[ -z "$QUIET" ]] && echo -e "\n Done!! :D \n"
[[ -z "$QUIET" ]] && cat <<- EOF
Speed Champion: $champ_speed_model with a tokens/seconds of ${champ_speed_num}!
Time Champion: $champ_time_model with a time of ${champ_time_num}!
echo -e "\n Done!! :D \n"
cat <<- EOF
Speed Champion: $champ_s_mdl at ${champ_s_thr}-$champ_s_ctx with a tokens/seconds of ${champ_s_num}!
Time Champion: $champ_t_mdl at ${champ_t_thr}-$champ_t_ctx with a time of ${champ_t_num}!
EOF
# Finish
@@ -1800,8 +1819,8 @@ function ollama_benchmark() {
if [[ ! -d /sdcard && -d /etc/sv ]]; then
[[ -z "$QUIET" ]] && echo -e "\n Restarting runit service..."
sudo sv enable ollama
sudo sv start ollama
sudo sv enable ollama >/dev/null 2>&1
sudo sv start ollama >/dev/null 2>&1
[[ -z "$QUIET" ]] && echo " Done!"
fi