Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![.github/workflows/shellcheck.yaml](https://github.com/geerlingguy/ollama-benchmark/actions/workflows/shellcheck.yaml/badge.svg)](https://github.com/geerlingguy/ollama-benchmark/actions/workflows/shellcheck.yaml)

## Linux

This bash script benchmarks ollama on any system where it is installed.

For a quick installation, try:
Expand All @@ -26,7 +28,7 @@ Then run this benchmark script:

Uninstall Ollama following the [official uninstall instructions](https://github.com/ollama/ollama/blob/main/docs/linux.md#uninstall).

## CLI Options
###CLI Options

```
Usage: ./obench.sh [OPTIONS]
Expand All @@ -39,6 +41,26 @@ Options:
--markdown Format output as markdown
```

## Windows

This PowerShell script benchmarks ollama on any system where it is installed.

> Make sure you have Ollama installed on your windows machine

### CLI Options

```
Usage: .\obench.ps1 [OPTIONS]
Options:
-Help Display this help message
-Default Run a benchmark using some default small models
-Model Specify a model to use
-Count Number of times to run the benchmark
-Ollama-bin Point to ollama executable or command (e.g if using Docker)
-Markdown Format output as markdown
```


## Findings

### DeepSeek
Expand Down
83 changes: 83 additions & 0 deletions obench.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# PowerShell script to benchmark Ollama token generation rate
# Inspired by https://taoofmac.com/space/blog/2024/01/20/1800

param (
[switch]$Help,
[switch]$Default,
[string]$Model,
[int]$Count,
[string]$OllamaBin = "ollama",
[switch]$Markdown
)

function Show-Usage {
Write-Output "Usage: obench.ps1 [OPTIONS]"
Write-Output "Options:"
Write-Output " -Help Display this help message"
Write-Output " -Default Run a benchmark using some default small models"
Write-Output " -Model Specify a model to use"
Write-Output " -Count Number of times to run the benchmark"
Write-Output " -Ollama-bin Point to ollama executable or command (e.g if using Docker)"
Write-Output " -Markdown Format output as markdown"
exit 0
}

if ($Help) {
Show-Usage
exit 0
}

# Default values
if ($Default) {
$Count = 3
$Model = "llama3.2:3b"
}

# Ensure Ollama is available
$baseCmd = ($OllamaBin -split " ")[0]
if (-not (Get-Command $baseCmd -ErrorAction SilentlyContinue)) {
Write-Error "Error: $baseCmd could not be found. Please check the path or install it."
exit 1
}

# Prompt for benchmark count if not provided
if (-not $Count) {
$Count = Read-Host "How many times to run the benchmark?"
}

# Prompt for model if not provided
if (-not $Model) {
Write-Output "Current models available locally:"
& $OllamaBin list
$Model = Read-Host "Enter model you'd like to run (e.g. llama3.2)"
}

Write-Output "Running benchmark $Count times using model: $Model"
Write-Output ""
if ($Markdown) {
Write-Output "| Run | Eval Rate (Tokens/Second) |"
Write-Output "|-----|---------------------------|"
}

$totalEvalRate = 0
for ($run = 1; $run -le $Count; $run++) {
$result = echo "Why is the blue sky blue?" | & $OllamaBin run $Model --verbose 2>&1 | Select-String "^eval rate:"

if ($result) {
$evalRate = ($result -split " ")[1]
$tokenValue = ($evalRate -split " ")[0]
$totalEvalRate += [double]$tokenValue
if ($Markdown) {
Write-Output "| $run | $evalRate tokens/s |"
} else {
Write-Output $result
}
}
}

$averageEvalRate = [math]::Round($totalEvalRate / $Count, 2)
if ($Markdown) {
Write-Output "|**Average Eval Rate**| $averageEvalRate tokens/second |"
} else {
Write-Output "Average Eval Rate: $averageEvalRate tokens/second"
}