ollama-benchmark, fixes after doing a few more tests.

This commit is contained in:
me committed 2026-10-31 07:55:11 -07:00
1 parent ffbf55c1ed
commit c6a309ec82
1 file changed
+20 -10
+20 -10
View File
@@ -1579,7 +1579,7 @@ function ollama_benchmark_usage() {
IGPUS IGPUS
Values to set OLLAMA_IGPU_ENABLE to. Defaults to 1. Values to set OLLAMA_IGPU_ENABLE to. Defaults to 1.
MODELS MODELS
Model names to test. Defaults to all of `ollama ls`. Model names to test. Defaults to all of 'ollama ls'.
EXAMPLES: EXAMPLES:
@@ -1608,9 +1608,11 @@ function ollama_benchmark_usage() {
} }
function ollama_benchmark() { function ollama_benchmark() {
#############################################################################
# Parameters # Parameters
#############################################################################
if [[ "$@" == *"-h"* || "$@" == *"--help"* ]]; then if [[ "$@" == *"-h"* || "$@" == *"help"* ]]; then
ollama_benchmark_usage ollama_benchmark_usage
return 0 return 0
fi fi
@@ -1643,14 +1645,16 @@ function ollama_benchmark() {
[[ -z "$QUIET" ]] && cat <<- EOF [[ -z "$QUIET" ]] && cat <<- EOF
DEBUG=$DEBUG DEBUG=$DEBUG
QUIET=$QUIET QUIET=$QUIET
context=$context contexts=$contexts
threads=$threads threads=$threads
igpu=$igpu igpus=$igpus
model=$model models=$models
EOF EOF
[[ -z "$QUIET" ]] && echo " Done!" [[ -z "$QUIET" ]] && echo " Done!"
#############################################################################
# Variables # Variables
#############################################################################
col_mdl=25 col_mdl=25
col_hdd=6 col_hdd=6
@@ -1667,7 +1671,9 @@ function ollama_benchmark() {
declare champ_{s,t}_{mdl,num,ctx,thr} declare champ_{s,t}_{mdl,num,ctx,thr}
#############################################################################
# Functions # Functions
#############################################################################
function wait_for_ollama() { function wait_for_ollama() {
while ! ollama ps >/dev/null 2>&1; do while ! ollama ps >/dev/null 2>&1; do
@@ -1675,7 +1681,9 @@ function ollama_benchmark() {
done done
} }
#############################################################################
# Main # Main
#############################################################################
if [[ ! -d /sdcard && -d /etc/sv ]]; then if [[ ! -d /sdcard && -d /etc/sv ]]; then
[[ -z "$QUIET" ]] && echo -e "\n Stopping ollama runit service..." [[ -z "$QUIET" ]] && echo -e "\n Stopping ollama runit service..."
@@ -1696,8 +1704,8 @@ function ollama_benchmark() {
":------------------------" "-----:" "-------:" "-----:" "------:" "---:" "--------:" "----------:" "-------:" ":------------------------" "-----:" "-------:" "-----:" "------:" "---:" "--------:" "----------:" "-------:"
last_igpu="" declare last_igpu="" count=0
count=0 unset model context thread igpu
for model in $models; do for model in $models; do
for context in $contexts; do for context in $contexts; do
for thread in $threads; do for thread in $threads; do
@@ -1777,7 +1785,7 @@ function ollama_benchmark() {
champ_s_num="$speed" champ_s_num="$speed"
champ_s_mdl="$model" champ_s_mdl="$model"
champ_s_ctx="$ctx" champ_s_ctx="$ctx"
champ_s_thr="$thr" champ_s_thr="$thread"
fi fi
[[ -n "$DEBUG" ]] && echo "DEBUG: champ_t_num=$champ_t_num, time=$time" [[ -n "$DEBUG" ]] && echo "DEBUG: champ_t_num=$champ_t_num, time=$time"
@@ -1788,7 +1796,7 @@ function ollama_benchmark() {
champ_t_num="$time" champ_t_num="$time"
champ_t_mdl="$model" champ_t_mdl="$model"
champ_t_ctx="$ctx" champ_t_ctx="$ctx"
champ_t_thr="$thr" champ_t_thr="$thread"
fi fi
fi fi
@@ -1807,11 +1815,13 @@ function ollama_benchmark() {
echo -e "\n Done!! :D \n" echo -e "\n Done!! :D \n"
cat <<- EOF cat <<- EOF
Speed Champion: $champ_s_mdl at ${champ_s_thr}-$champ_s_ctx with a tokens/seconds of ${champ_s_num}! Speed Champion: $champ_s_mdl at ${champ_s_thr}-$champ_s_ctx with a tokens/second of ${champ_s_num}!
Time Champion: $champ_t_mdl at ${champ_t_thr}-$champ_t_ctx with a time of ${champ_t_num}! Time Champion: $champ_t_mdl at ${champ_t_thr}-$champ_t_ctx with a time of ${champ_t_num}!
EOF EOF
#############################################################################
# Finish # Finish
#############################################################################
[[ -z "$QUIET" ]] && echo -e "\n Killing local ollama serve..." [[ -z "$QUIET" ]] && echo -e "\n Killing local ollama serve..."
killall ollama killall ollama